Professional Documents
Culture Documents
Process Control Blocks Linux PCBS: Operating Systems Operating Systems 2
Process Control Blocks Linux PCBS: Operating Systems Operating Systems 2
PCBs
Where the OS can find all the information it needs to know
about a process.
In the same order as the previous slide.
• memory
/* memory management info */
• open streams/files struct mm_struct *mm;
• devices, including abstract ones like windows /* open file information */
• links to condition handlers (signals) struct files_struct *files;
• processor registers (single thread) /* tss for this task */
• process identification struct thread_struct tss;
• process state - including waiting information int pid;
• priority volatile long state; /* -1 unrunnable, 0
runnable, >0 stopped */
• owner
long priority;
• which processor
unsigned short uid,euid,suid,fsuid;
• links to other processes (parent, children) #ifdef __SMP__
• process group int processor;
• resource limits/usage #endif
• access rights struct task_struct *p_opptr, *p_pptr,
• process result - may be waited for by another process *p_cptr, *p_ysptr, *p_osptr;
/* limits */
Doesn't have to be kept together
struct rlimit rlim[RLIM_NLIMITS];
Different information is required at different times
long utime, stime, cutime, cstime,
UNIX for example has two separate places in memory with start_time;
this information. One of them is in the kernel the other is
in user space. Windows does the same.
Process Table
Kernel Process Block (KPROCESS) includes A collection of PCBs
info the kernel needs to schedule threads Commonly an array of pointers to PCBs
• Kernel and user times.
• Pointers to threads. Thread structures (like PCBs)
• Priority information.
• private memory (runtime stack) and static storage for
• Process state local variables
• Processor affinity • processor registers
• thread identification
Process Environment Block (PEB) includes • thread state - including waiting information
info which needs to be writable in user • priority
mode • processor
• image info: base address, version numbers, module list • associated process
• heaps (blocks of one or more pages) • thread group
• thread result - maybe waited for by another thread
Test exec
1. copy on write • open .exe file and create a section object (actually
quite complex because of the different subsystems)
No copy is made at first.
• create NT process object
The data pages of the parent process are set to read only.
• Set up EPROCESS block
If a write occurs the resulting exception makes a copy of the
• create initial address space
page for the other process – both copies are then marked
writable. • create KPROCESS block
• finish setting up address space - including mapping the
section object
1. vfork • adds process block to the end of the list of active
Trust the programmers to know what they are doing. processes
• set up PEB
With vfork - parent process blocks until child • creates initial thread (initially suspended)
finishes or calls exec. • Win32 subsystem is notified about the new process
How many calls to ps are created by the earlier code if we (includes the arrow and hourglass cursor)
could use vfork? • initial thread starts
• goes through more startup in the context of the new
process - includes loading and initializing DLLs
Copy on write is the predominant strategy.
It is used in many situations to improve throughput.