Process
Process: The abstraction provided by the OS of a running program
The OS provides an illusion of unlimited CPUs by virtualization
Time Sharing is a basic technique used by an OS to share a resource. By allowing the resourece to be used for a little while by one entity, and then a little while by another, and so forth.
Process API
- Create: create a new process.
- Destroy: destroy process forcefully
- Wait: wait for a process to stop running
- Miscellaneous Control: some other types of control (i.e. suspend)
- Status: Get status information
Process Creation
- Program initially resides on disk in some form of executable]
- OS load the program into memory (Modern OS does lazy loading, only load data/code when needed)
- Allocate memory for the program’s run-time stack
- Allocate memory for the program’s heap
- Other initialization tasks such as I/O setup
- Start the proogram running at the entry point
main()
(In C, stack is used for local variables, function parameters, and return addresses. The heap is used for dynamically-allocated data (linked lists, hash tables, etc))
Process States
- Scheduled: ready -> running
- Descheduled: running -> ready
- Blocked
Thread
- The smallest sequence of progremmed instructions that can be managed independently by a scheduler
- Has its own registers
- Most programs are single threaded:
Parallel Computing
- Run programs currently on one or more CPUs
- Multi-threading (shared-memory)
- Multi-processing (independent-memory)