Storing and retrieving process control block

后端 未结 3 1638
广开言路
广开言路 2021-02-02 03:26

When a process is in execution, the contents of the PCB (which is in kernel memory space?) are loaded onto the CPU registers, and status registers, kernel

3条回答
  •  不思量自难忘°
    2021-02-02 04:04

    I would like to provide bit detail information (& to make it easy to understand, consider there is ONE kernel thread per process).

    Now there is thread context (eip, ebp, esp, pagedir, kstack, kstacksize) with the every kernel thread (kthread). So, as we all know the thread/process life cycle, it passes through the states like - "Running, Runnable, wait, exit". When the thread is in the running state, its context is in the kernel data structure "context_t" stored somewhere in the kernel address space. and the kernel stack contains the pointer to that data structure When the thread switch (in more technical words we should say context_switch) happens (reason may be - scheduler cpu time out, I/O operation completion etc.) the thread is enqueued into the runnable queue kernel data structure (waiting for its chance to get CPU).

    When states become 'Running', context switch happens again and now the context_t gets loaded. which has all the necessary pointers to access the previously stored data members which will be used now to continue form the previously halted state.

    All kernel data structures are stored in the kernel address space (> 0xc0000000) and thread has pointers to these block of context. (as threads gets switched, the new thread points to its context - again context switch, next thread points to its own data structure.

提交回复
热议问题