Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Topics: 11/1 General Operating System Concepts Processes

Similar presentations


Presentation on theme: "Lecture Topics: 11/1 General Operating System Concepts Processes"— Presentation transcript:

1 Lecture Topics: 11/1 General Operating System Concepts Processes
processes vs. programs Process Management process control blocks Address Spaces Threads

2 HW5 Turnin Turn in your shell.exe via the web
courses/410/CurrentQtr/hw/turnin_hw5.html Link to it from the class web Limited to 2MB file (turn in release version if it’s too big)

3 Review: What is an O.S? Operating system implements a virtual machine that is easier to program than the raw hardware Application Virtual Machine Interface Operating System Physical Machine Interface Hardware

4 Review: What does an O.S. do?
Coordinator—allow multiple apps/users to work together fairly and efficiently security (I can’t trash your memory) communication (we can work together) resource management (CPU, memory, disk) Provider of standard services—most programs have basically the same needs standard libraries, window system, file system What if there was no O.S.? Source code  compiler  executable  hardware How does the executable get onto the hardware? How do you get the output of your program?

5 Review: O.S. History Originally, HW was expensive and humans were cheap OS was optimized for the HW Now, HW is cheap and humans are expensive OS optimized for humans

6 What does an O.S. look like?
Hardware (CPU, devices) Application Interface (API) Hardware Abstraction Layer File Systems Memory Manager Process Manager Network Support Device Drivers Interrupt Handlers Boot & Init PowerPoint Solitaire IE Operating System Portable

7 Dual Mode Operating system can do things that a user program cannot. Examples? Two modes of execution user mode (applications) supervisor mode (operating system) Privileged instructions can only be called in supervisor mode (e.g. halt) Hardware implements this with a “mode bit” in the CPU mode bit = 0, no privileged instructions mode bit = 1, can do anything

8 Getting control back How does the OS get control back from a running process? The process could explicitly return control to the OS (in many real-time systems) We can’t trust the process to do this OS sets a timer on the CPU (privileged instruction) and starts a user process When the timer expires control is passed to the OS timer expires 100–1000 times per second

9 Processes vs. Programs A program is passive A process is active
just a file on the disk with code that is potentially runnable A process is active one instance of a program in execution also called job, task, sequential process At any given time, there may be many processes running the same program even though they run the same program, they are separate and independent What state defines a process?

10 What’s in a Process? A process consists of at least:
the code for the running program the data for the running program an execution stack tracing the state of procedure calls made the Program Counter, indicating the next instruction a set of general-purpose registers with current values a list of open files and open network connections

11 Process State Each process has an execution state that indicates what it is currently doing: ready: waiting to be assigned to the CPU running: executing instructions on the CPU waiting: waiting for an event, e.g., I/O completion As a program executes, it moves from state to state

12 Process State Changing
new running terminated ready waiting Processes move from state to state as a result of actions they perform (e.g., system calls), OS actions (rescheduling) and external actions (interrupts)

13 Process Data Structures
At any time, there are many processes active in a system The OS must have data structures representing each process this data structure is called the PCB (Process Control Block) The PCB contains all of the info about a process, when the process is not running

14 PCB PCB contains lots of information, e.g.: process state
process number program counter stack pointer 32 general-purpose registers memory management info username of owner queue pointers for state queues scheduling info (priority, etc.) accounting info

15 PCBs and Hardware State
When a process runs, its PC, SP, and registers, are loaded on the CPU When the OS switches to a new process, it saves the current process’s register values to its PCB loads the next process’s register values from its PCB This is called a context switch. It occurs times per second why so often? why not more often?

16 State Queues OS maintains a collection of PCB queues for each possible state PCB Word PCB Tetris PCB MSVC Ready Queue Header head ptr tail ptr Wait Queue Header head ptr PCB Defrag PCB Telnet tail ptr Many wait queues—one for disk, one for user input, etc.

17 PCBs and State Queues PCBs are data structures in OS memory
A PCB is created for a process when it starts and put on the ready queue While the process is active, PCB is on one of the state queues When the process is terminated, its PCB is deallocated (after a little while)

18 Address Spaces An address space is the range of addresses that a process may use The legal address space is the range of addresses that a process may use right now Reserved Text Static data Heap and stack

19 Address Spaces How can multiple programs use the same addresses?
base register (value added to every memory reference) How do you protect one program against the others? bounds register (no memory reference allowed beyond here) Now computers use virtual memory to solve these problems Memory Word Solitaire NT base reg =0x200000 bounds reg =0x500000 base reg =0x600000 bounds reg =0x700000

20 Processes and Address Spaces
Each process has its own address space Process A’s memory references (loads and stores) are interpreted within process A’s address space Can Process A load a word from Process B’s address space? Can Process A load a word from kernel memory?

21 Threads An address space defines a process
A thread is a sequential execution stream Multiple threads share the same address space What state does a thread share with other threads in the process? What state does a thread not share with other threads in the process?


Download ppt "Lecture Topics: 11/1 General Operating System Concepts Processes"

Similar presentations


Ads by Google