OS Discussion - Session 2
Chapter 4
Date: 26th Jan 2018 Reference:
The Abstraction: The process
- Process: Simply a running program.
- Program is just a bunch of instructions.
- OS takes these instructions and sets them running.
- Transforms a program into a process.
- Virtualisation: The illusion that each process has its own CPU.
- There are a lot of process running simultaneously.
- Each process needs to access CPU resources.
- Time sharing is a method used to share the CPU time among processes.
- Each process feels that the entire CPU is dedicated to it.
- But in reality, CPU shares its resources with everybody.
- How to accomplish virtualisation ?
- Mechanisms: Low level machinery.
- Example: Context Switch which allows to switch between processes for time sharing.
- Policies: High level machinery.
- Policies are used for decision making in the OS.
- Example: Job scheduling policies like LRU to decide which programs should be run.
- Process API: Interfaces used to directly interact with the OS.
- Create: Interface for creating a new process.
- Destroy: Interface to forcefully killing a particular process if not shut automatically.
- Wait : Waiting interface to wait for a process to do something.
- Status: Interface to get status info.
- Miscellaneous Control: Interface for other purpose like suspending a certain application.
- Process Creation:
- OS loads data and code from disk to main memory.
- Earlier: Eager Loading, i.e, all loaded at ones.
- Now: Lazy Loading, i.e, Load most important parts.
- Some memory for program’s run time stack.
- Stack: Local variables , function parameters, return addresses, etc.
- Some memory for heap used for dynamically allocated data.
- Heap: Used for linked list, trees, hash tables, etc.
- Process States:
- Running: Process running on a processor
- Ready: Ready to run but currently not run by OS at the given moment.
- Blocked: Process not ready to run until some event like I/O occurs.
- Data Structures: OS wants to know what the process is doing. Hence, some data structures are required to maintain relevant info. About the process.
- Process Control Block(PCB) : Analogous to a process list.
- PCBs keeps track of all running programs of the system.
- Every process has a particular execution context.
- Executions contexts are used for context switching between processes for time sharing.
Future Discussion Points:
- What is the idea and use of kernel stack and how is it different form any other kind of stack like user stack?
- What are the various items stored in heap or stack while process execution.
- What is the idea of space sharing in process creation and execution.
- What are the differences between fork() and exec() system calls?