1 / 22

Operating Systems - process

Operating Systems - process. Seehwan Yoo Mse.cis.dku. Review. Computer systems organization (hardware) Main components CPU: instruction execution Memory: store data/instruction (program) I/O devices: interact with outer world Bus: an inter-connect across hw Address Data Control.

yadid
Download Presentation

Operating Systems - process

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. OperatingSystems- process Seehwan Yoo Mse.cis.dku

  2. Review • Computer systems organization (hardware) • Main components • CPU: instruction execution • Memory: store data/instruction (program) • I/O devices: interact with outer world • Bus: an inter-connect across hw • Address • Data • Control • Input/output device operation • Accessing registers • Mem-mapped I/O • I/O-mapped I/O • Event checking • Interrupt: notify of event to cpu • Polling: cpu manually checks status • DMA • Bulk data transfer • Avoid cpuintervention

  3. Review • Operating systems structure • Kernel • User programs • Dual-mode OS: protection support by hw • User mode • Kernel mode • System call • OS service call • Across protection boundary (from user to kernel) • No API, but ABI • Multi-user systems • Multi-programming: running multiple user applications

  4. Process & execution context • Program in execution • Abstraction for processor • Every process has its own execution ‘context’ • CPU register values • Incl. PC, SP, A0, V0, … • Address space (memory) • State • Open files

  5. Program vs. process Program Process Loaded in memory Has execution context PC, SP, live registers, open files, memory contents • Stored in disk • No active execution context • No PC, no SP, no run-time data

  6. Process Memory or address space • Address • of your home? • Address is given to memory location • LW/SW (load/store) data to some memory location • Address space • Set of address {from begin to end} • {0, …, 4G} (for 32bit machine) • Process has its own address space • Every process runs only within his own address space • Will be addressed, later (in virtual memory chapter)

  7. Memory layout • Process should have memory region for • Text: program code • Data • Stack • Heap • And kernel • All above within 0~4G address space • Written in your program

  8. Time-sharing system • Multiple processes run concurrently • assumption: 1 CPU system • OS makes illusion • Feels like each process has its own CPU • And all processes run at the same time • Conceptually, • Make process A run, then stop • Make process B run, then stop • …

  9. Time-sharing system’s implementation • Timer runs • Generates timer interrupts periodically • 1s/ 10ms/ 1ms • Like heartbeat • When CPU gets timer interrupt, • Account CPU usage of the process • Time quantum (or time slice): max. time given to a process without interruption • When a process consumes all its quantum, change the runningprocess • Scheduler determines which process to run (at when)

  10. Process states • New • Running • Waiting • Ready • Terminated

  11. Process state transition diagram

  12. Process state transition when? • New ready • Ready  running • Running  ready • Running  waiting • Waiting  ready • Running  terminated

  13. Process state transition when? • New ready : process creation completion • Ready  running : scheduler dispatch • Running  ready : time quantum expired, preempted by another process • Running  waiting : I/O req. • Waiting  ready : I/O completion • Running  terminated : exit(), unexpected exceptions

  14. PCB – process control block • Data structure of process inside kernel • task_struct in Linux • pidt_pid; /* process identifier */ long state; /* state of the process */ unsigned inttime_slice /* scheduling information */ structtask_struct *parent; /* this process’s parent */ structlist_head children; /* this process’s children */ structfiles_struct *files; /* list of open files */ structmm_struct *mm; /* address space of this process */

  15. Context switching • Triggered by various events • Time quantum expired, I/O completion, etc. • Exchange running process with one of ready processes

  16. Scheduler - Switching the execution context

  17. Analogy in context switching, interrupt handling • When interrupt/context switching occurs, • Stop the current execution • Save regs on the PCB • Handle interrupt / exchange PCB (by scheduler) • Return to the previous execution • Load regs (values) back from PCB • PC / SP ? • Help of hw (arch.) • Return address reg. • Separate pc/sp for user applications

  18. Scheduling – Choose a process to run • Scheduling queue: data structure for storing process in various states • Ready queue • Device queue

  19. Scheduling queues

  20. Overall picture of scheduling

  21. Let’s look into Scheduling in the next class!

  22. Summary page • Process concept • Cf. program • Memory layout • Address space • Execution context • PCB • Context switching • Scheduler operation • Process state diagram

More Related