Lecture 4: Processes 1 Flashcards
Role of the OS:
- Resource Abstraction
- Resource Sharing
Supported in the these ways:
- Process and thread management (resource: CPU)
- Memory management (resource: Memory)
- File management (resource: Secondary Storage)
- I/O system management (resource: Devices)
- Protection system (resource: All)
- Command-interpreter system (resource: All)
Shell (or Command-Line-Interpreter)
- A shell is a job control system which allows the programmer to create and manage a set of programs to do some task.
- it is a program that reads and interprets control statements.
- The “visible face” of an OS (sometimes with GUI (e.g.: Windows)
® Process creation and management ® I/O handling ® Secondary storage management ® Main memory management ® File system access ® Protection
Control Statements of the Shell
User-driven commands to the OS (vs. event-driven commands such as interrupts)
Process
-program in execution
How Is a Process an Abstraction of the CPU?
- Gives an illusion of a uniprogramming environment
- Every process acts as though it has exclusive access to the CPU
In Reality: Multiprogramming
- CPU is time-sliced:
processes take turns using the CPU - Memory is space-sliced:
processes get partitions
Threads
- Lightweight process (no isolation)
- Abstraction only of CPU
- One process can have many threads (multithreading), all share the same memory
Difference between threads and processes
- Threads: mostly cooperative. Processes: mostly independent –a thread communication is inexpensive (via shared memory)
- a e.g., a user can type characters and have the speller running - Threads more appropriate for certain applications
What makes up a process?
- Code section (text segment)
- Data section (data segment)
- Stack (stack segment)
- Registers (including Program Counter)
Program vs Process
- Program is a passive entity
- an executable stored in disk
Process is a dynamic entity
-a program becomes a process when it is loaded into memory
Process Control Block (PCB)
Processes Represented In Memory with Current “State”
Context Switch
- process with access to CPU switched out (state copied to PCB)
- another ready process switched in (state copied from PCB)
Process Scheduling: Multiprogramming Goal
- maximize CPU utilization
- have some process running (using the CPU) all time
Process Scheduling: Time –sharing Goal
- users can interact with their running programs
- switch CPU among processes frequently enough
Process Scheduler
it selects the
process for program execution on the CPU