Operating Systems CMPSC 473
130 likes | 287 Vues
Operating Systems CMPSC 473. Processes August 26, 2010 - Lecture 2 Instructor: Bhuvan Urgaonkar. Last class. Definition of an operating system Software that virtualizes physical resources for applications CPU, memory, IO devices virtualized to process, virtual memory, and files
Operating Systems CMPSC 473
E N D
Presentation Transcript
Operating SystemsCMPSC 473 Processes August 26, 2010 - Lecture 2 Instructor: Bhuvan Urgaonkar
Last class • Definition of an operating system • Software that virtualizes physical resources for applications • CPU, memory, IO devices virtualized to process, virtual memory, and files • OS requires a variety of support from hardware • For protecting processes from each other and to control their resource usage -> User/Kernel Modes
Announcements • A brief tutorial on using gdb in the next class • Slides up on Angel
Services & Hardware Support • Protection: Kernel/User mode, Protected Instructions, Base & Limit Registers • Scheduling: Timer • Interrupts: Interrupt Vectors • System Calls: Trap Instructions • Efficient I/O: Interrupts, Memory-mapping • Synchronization: Atomic Instructions • Virtual Memory: Translation Lookaside Buffer (TLB)
Interrupts • Polling = “are we there yet?” “no!” (repeat…) • Inefficient use of resources • Annoys the CPU • Interrupt = silence, then: “we’re there” • I/O device has own processor • When finished, device sends interrupt on bus • CPU “handles” interrupt
CPU Interrupt Handling • Handling interrupts: relatively expensive • CPU must: • Save hardware state • Registers, program counter • (Often) disable interrupts (why?) • Invoke via in-memory interrupt vector (like trap vector, soon) • Enable interrupts • Restore hardware state • Continue execution of interrupted process
Traps • Special conditions detected by architecture • E.g.: page fault, write to read-only page, overflow, system call • On detecting trap, hardware must: • Save process state (PC, stack, etc.) • Transfer control to trap handler (in OS) • CPU indexes trap vector by trap number • Jumps to address • Restore process state and resume
Timer • OS needs timers for • Time of day • CPU scheduling • Interrupt vector for timer
Process: Definition • For us: Instance of a program in execution • For OS: The collection of data structures that fully describes how far the execution of the program has progressed • From kernel’s point of view, an entity to which system resources (CPU time, memory, …) are allocated
Overview of Process-related Topics • How a process is born • Parent/child relationship • fork, clone, … • How it leads its life • Loaded: Later in the course • Executed • CPU scheduling • Where a process “lives”: Address space • OS maintains some info. for each process: PCB • Process = Address Space + PCB • How processes request services from the OS • System calls • How processes communicate • A variant of processes: threads • How processes die
Process Address Space • Text section • Stack • Temporary data • Function params, return addresses, local variables • Data • Global variables • Heap • Used for dynamically allocating memory
Process Life-cycle • New: Being created • Running: Instructions are being executed • Only one process can be in this state at any given time per-CPU • Waiting: Waiting for some event to occur (e.g., I/O completion or reception of a signal) • Ready: Waiting to be assigned the CPU • Terminated: Finished execution