Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can.

Similar presentations


Presentation on theme: "Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can."— Presentation transcript:

1 Chapter 4 Processes

2 Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can also have suspended or waiting processes

3 Memory Management Issues Each process needs its own avail pointer Each process needs its own avail pointer Heap needs to be setup when process is created Heap needs to be setup when process is created

4 Process States New New Running Running Waiting Waiting Ready (Suspended) Ready (Suspended) Terminated Terminated

5 Process State Diagram new ready running waiting terminated admittedexit interrupt scheduler dispatch IO or event completionIO or wait event

6 Process Control Block pointer process state process number program counter registers memory limits list of open files......

7 Process Control Block Process state Process state ready, running, waiting … ready, running, waiting … Program counter Program counter next instruction to be executed next instruction to be executed CPU registers CPU registers process context (what am I working on) process context (what am I working on) Scheduling Information Scheduling Information priority, pointers to scheduling queues … priority, pointers to scheduling queues … Memory-management info Memory-management info base and limit registers, page tables, segment tables base and limit registers, page tables, segment tables IO status information IO status information open files, I/O devices open to this process … open files, I/O devices open to this process …

8 Loading a Process Find Process on Disk Find Process on Disk Get size of process Get size of process Add PCB to process table Add PCB to process table Allocate memory Allocate memory Assign memory to process Assign memory to process Assign stack space, and heap Assign stack space, and heap set up the bounds registers set up the bounds registers put process in memory put process in memory

9 Buffering a File bufferFile Vector Address:0x1C Registers Used:r0, r1 Input Parameters: r1  &filename Returned Value(s): r0  failed = 0 succeeded = 1 r1  size of code r2  size of data Operation(s):

10 Load File Vector Address:0x1D Registers Used:r0, r1 Precondition: File is in buffer Input Parameters: r0  code address r1  data address Returned Value(s): r0  failed = 0 succeeded = 1 r1 

11 Running a Process Set up stack Set up stack Set the process state to run Set the process state to run Change program counter to process begin Change program counter to process begin Other issues?? Other issues??

12 Terminating a process hlt?? vs interrupt 20 hlt?? vs interrupt 20 Context switch to OS Context switch to OS Disable interrupts Disable interrupts Set process status to terminated Set process status to terminated de-allocate memory de-allocate memory clean up resources clean up resources remove pcb from process table remove pcb from process table Enable interrupts Enable interrupts

13 Suspending a process disable interrupts disable interrupts save process context save process context set process status to suspended set process status to suspended enable interrupts enable interrupts

14 System Commands dirmake a system call cwdmake a system call loadload a file into memory runrun a process psprint out the processes in memory helpjust print out the help exitmake a system call memShow the contents of memory (system) freeShow the amount of free memory (system)

15 Running the Shell In shell process In shell process get command string get command string parse command parse command switch on command switch on command Set up command parameters Set up command parameters Execute command Execute command get next command get next command

16 Executing a command Two options Two options Do the command in the shell Do the command in the shell Spawn a new process Spawn a new process Which one is better?? Which one is better??


Download ppt "Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can."

Similar presentations


Ads by Google