Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD

Similar presentations


Presentation on theme: "Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD"— Presentation transcript:

1 Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD cshen@cis.udel.edu

2 Process Process is a running program –A program itself is a lifeless thing sitting on disk with instructions (and static data) –OS transforms a program into a running process Need to run many processes at once Problem: how to provide the illusion of many CPUs? –virtualize the CPU – run one process, stop it, and then run another process, etc. –time sharing –scheduling policy & context switching mechanism

3 Machine State of Process Address space (including stack) http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/Mips/stack.html CPU registers (including PC, SP, FP) Opened files

4 Process API Create – a process is created when an application icon is double-clicked Destroy Wait Miscellaneous control – stop & resume Status

5 Process Creation Load code and static data into memory (address space) Initialize (run-time) stack with argc & argv Initialize 3 default file descriptors (0, 1, and 2) Jump to main()

6 Process State (Life Cycle) Running – using CPU Ready – someone else is using CPU Blocked – not ready until some other event takes place (e.g., initiate I/O request to disk)

7 Data Structures of OS OS is a program itself containing data structures Process lists (or queues) –running queue (single CPU) –ready queue –I/O queues PCB (Process Control Block) –register context –process state –for context switching

8 PCB in xv6 Kernel struct context { // registers saved/restored in context switch int eip; int esp; int ebx; int ecx; int edx; int esi; int edi; int ebp; }; enum proc_state // process state { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; struct proc { // PCB char *mem; uint sz; char *kstack; enum proc_state state; int pid; struct proc *parent; void *chan; int killed; struct file *ofile[NOFILE]; struct inode *cwd; struct context context; struct trapframe *tf; };


Download ppt "Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD"

Similar presentations


Ads by Google