Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating System I Processes. F “A program in execution” F Modern computers allow several at once –“pseudoparallelism” A B C Program Counter A B C B A.

Similar presentations


Presentation on theme: "Operating System I Processes. F “A program in execution” F Modern computers allow several at once –“pseudoparallelism” A B C Program Counter A B C B A."— Presentation transcript:

1 Operating System I Processes

2 F “A program in execution” F Modern computers allow several at once –“pseudoparallelism” A B C Program Counter A B C B A CConceptual View Time

3 Processes F “A program in execution” “more” than a program: ls, tcsh “less” than a program: gcc blah.c (cpp, cc1, cc2, ln …) F “A sequential stream of execution in it’s own address space” main() {... } A() { … } main() {... } A() { … } Heap A main Stack

4 Process States F Consider: cat /etc/passwd | grep claypool WaitingRunningReady New Dispatch Interrupt I/O Wait I/O Complete Exit (Hey, you, show states in top !)

5 Design Technique: State Machines F Process states F Move from state to state based on events –Reactive system F Can be mechanically converted into a program F Other example: –string parsing, pre-processor

6 Unix Process Creation  System call: fork() –creates (nearly) identical copy of process –return value different for child/parent  System call: exec() –over-write with new process memory F (Hey, you, show demos!)

7 Java Process Creation  “fork” and “exec” rolled into exec() public Process exec(String command) –args separated by whitespace F Child Process output:status: –getOutputStream()- waitFor() –getInputStream()- exitValue() –getErrorStream()- destroy() F Depends upon underlying OS proc support!

8 Process Scheduler catls... disk Scheduler vid F All services are processes F Small scheduler handles interrupts, stopping and starting processes

9 Process Control Block F Each process has a PCB –state –program counter –registers –memory management –… F OS keeps a table of PCB’s, one per process F (Hey! Simple Operating System, “system.h”)

10 Question F Usually the PCB is in OS memory only. F Assume we put the PCB into a processes address space. F What problems might this cause?

11 Interrupt Handling F Stores program counter F Loads new program counter –jump to interrupt service procedure F Save PCB information F Set up new stack F Set “waiting” process to “ready” F Re-schedule (probably awakened process) F If new process, called a context-switch

12 Context Switch F Pure overhead F Fast, fast, fast –typically 1 to 1000 microseconds F Sometimes special hardware to speed


Download ppt "Operating System I Processes. F “A program in execution” F Modern computers allow several at once –“pseudoparallelism” A B C Program Counter A B C B A."

Similar presentations


Ads by Google