Operating Systems Review (Unit 2: Process and Threads) Points to Remember: 1. Process : It is a program in execution 2. Components of the process are: Object program The input data Resources (E.g., files, etc.) PCB – Process Control Block, containing the state of the process in execution. 3. Difference between program and process: Program Process Dynamic entity that contains Object Static entity made up of source program, the input data, Resources and program language statements PCB. 4. PCB: OS creates a PCB (process control block table) for each process to manage that process.
5. Process States and valid transitions between them
o New State ( means a process that just been created) o Ready State (means a process that is prepared to execute) Running State (means a process is currently being executed)
Waiting state ( means a process is waiting for some event to occur) Terminated (means a process is just been terminated) 6. Cooperating Processes: A process is said to be a cooperating process if it can affect or be affected by other processes in the system. Advantages: o Information Sharing. o Computation Speedup 7. Types of inter process communication: Shared Memory: Processes can exchange information by reading and writing data to the shared region.
Message passing: Processes communicate by passing messages. SEND and RECEIVE primitives are used. 8. Message passing Types: Blocking Send, Blocking Receive: Both receiver and sender are blocked until the message is delivered. Non-Blocking Send, Blocking Receive: Sender can continue the execution after sending a message; the receiver is blocked until message arrives. Non-Blocking Send, Non-Blocking Receive: Neither party waits. 9. Remote Procedure Call: To execute a procedure at a remote site and ship the results back. 10. Thread: Thread is a light weighted process. A thread is a basic unit of CPU utilization. Example 1: A Web browser might have one thread display images or text while another thread retrieves data from the network. Example 2 : A word processor may have a thread for displaying graphics, another thread for responding to keystrokes from the user, and a third thread for performing spelling and grammar checking in the background. Advantages: Responsiveness, Resource sharing, Economy, Scalability. 11. Difference between Threads and processes: Processes Heavy weighted Processes don’t share an address space When a process is created memory is allocated to store instructions and data.
Threads Light Weighted Threads share an address space When a thread is created only registers and stack are allocated.
12. Multi-threading Models: • Many to One Model: - Many user-level threads mapped to single kernel thread. - Examples: Solaris Green Threads - Advantages: Easy to implement. - Disadvantages: Parallelism is not possible • One-to-One Model: - Each user-level thread maps to kernel thread. - Examples: Windows 95/98/NT/2000, Linux - Advantages: Parallelism is achieved. - Disadvantages: Costly • Many-To-Many Model - It multiplexes any number of user threads onto an equal or smaller number of kernel threads. - Example: HP-UX
13. Difference between user level and Kernel level Threads: Kernel Level Threads User Level Threads Threads implemented inside the OS It is implemented in user-level libraries Thread operations are system calls All operations are normal procedure calls Advantage: It is good for those Advantage: Simple, Fast and Efficient applications that are frequently block than kernel threads Disadvantage: They are slow and Disadvantages: Lack of coordination inefficient. between threads 14. Schedulers: Long-term scheduler (or job scheduler) : It selects which processes should be brought into the ready queue. Short-term scheduler (or CPU scheduler) : It selects which process should be executed next and allocates to CPU .
15. Scheduling Criteria a. Processor Utilization b. Throughput c. Turnaround Time (tat) d. Waiting Time (wt) e. Response Time (rt) 16. Scheduling Algorithms FIFO (or FCFS) Shortest-Job-First (SJF) Priority-based Round-robin Multilevel Queue Multilevel feedback queue
Refer Class notes for Scheduling problems 17. Preemptive and non-preemptive scheduling: Preemptive – if a new process with CPU burst less than remaining time of current process, preempt the current process. Non-preemptive scheduling: Once CPU assigned, process not preempted until its CPU burst completes.