1 / 8

Chapter 4 Process Abstraction

Chapter 4 Process Abstraction. Chien -Chung Shen CIS, UD cshen@cis.udel.edu. Process. P rocess 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

Télécharger la présentation

Chapter 4 Process Abstraction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4Process 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 inteip; intesp; intebx; intecx; intedx; intesi; intedi; intebp; }; enumproc_state// process state { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; structproc { // PCB char *mem; uintsz; char *kstack; enumproc_statestate; intpid; structproc *parent; void *chan; intkilled; structfile *ofile[NOFILE]; structinode *cwd;structcontext context; structtrapframe *tf; };

More Related