CSCE 313 Lecture 4
Jump to navigation
Jump to search
« previous | Thursday, January 26, 2012 | next »
Programs, Processes, and Threads
a process is an instance of a program that is executing.
processes are controlled by the OS:
- allocates memory, and manages resources (scheduling)
- coordinates processes among themselves (synchronization)
- assigns an ID (process ID)
- corresponds an ID with the process's state
Memory Layout of a Process
High Address → Low Address:
- command-line args and env. vars.
- stack (activation records for func calls)
- heap
- uninitialized static data
- initialized static data
- program text
States of a Process
From the user's point of view, the process executes continuously. In reality, several processes compete for CPU and other resources.
- running
- process holds the CPU and executing is instructions
- blocked
- process is waiting for some I/O event to occur
- ready
- waiting to get back on the CPU
Context Switching
System saves states of running process and loads state of new process.
A Context-Switch is overhead; no useful work is done while switching.
Process Control Block
- Process Identification
- Process ID
- Parent Process ID
- Userid
- etc...
- Processor State information
- Register set
- Condition codes
- Processor Status
- Process Control Information
- Process State
- Scheduling Information
- event (wait-for)
- Memory Management Information
- Owned resources (e.g. list of opened files)
Scheduling Queues
Processes migrate among the various queues:
- Job Queue
- set of all processes in the system
- Ready Queue
- set of all processes in main memory, ready, and waiting to execute
- Device Queue
- set of all processes waiting for an I/O device
Schedulers
- long-term (job scheduler)
- selects which processes should be brought int othe ready queue
- controls degree of multiprogramming
- selects a good mix of I/O-bound and CPU-bound proceses
- short-term (CPU scheduler)
- selects which process should be executed next and allocates CPU
- executes at least every 100ms, so must be very fast
- medium-term (swapper)
- in some operating systems
- temporarily removes processes from memory (suspending)
Process Creation
Parent creates children processes, which then make their own, forming a tree.
Resources may or may not be shared.
Parent and children may execute concurrently or the parent could wait until the children terminate.