What is context in xv6?

what is the usage of context in xv6 OS ? what is the job of each register in context ?

struct context {
  uint edi;
  uint esi;
  uint ebx;
  uint ebp;
  uint eip;
};

Upvotes: 2

Views: 2749

Answers (2)

Morass
Morass

Reputation: 323

This structure is the kernel context of the running process.

The user mode context is saved into the trapframe structure.

Upvotes: 2

mike
mike

Reputation: 220

context is that set of information that allows you to resume execution of a task from the exact same point where it stopped due to context switch (i.e. the scheduler selects another task to run and suspends the current one, hence it has to save the execution information of the current task and restore those of the next task to run).

The purpose of each of those registers is:

  • edi: Destination index, for string operations
  • esi: Source index, for string operations
  • ebx: Base index, for use with arrays
  • ebp: Stack Base Pointer, for holding the address of the current stack frame
  • eip: Instruction Pointer, points to instruction to be executed

Upvotes: 8

Related Questions