Processes can communicate with each other through inter-process communication mechanisms such as pipes, shared memory, and message queues.
An operating system's primary function is to allocate and manage computer resources efficiently so that multiple users or applications can run simultaneously without interfering with one another.
Operating systems are designed to manage computer hardware, including input/output devices such as keyboards, mice, printers, and storage devices like hard drives and optical disks.
File systems store data and allow it to be accessed by various applications.
Memory management involves allocating physical RAM to running programs and managing virtual memory swapped between disk and RAM.
There are three main states for a process and all threads: Running, Ready, Blocked.
Blocking process is an important concept in process management.
An OS knows it can make no useful progress so it is ineligible to run until it can make progress.
A blocked process will always transition through ready before running.
A running process can block based on kernel requests for temporarily unavailable resources.
Ready processes move to running when the scheduler selects them.
Most OSes provide a manual mechanism for the user to block a process (ready or running).
The main responsibilities of process management include scheduling, blocking, creating, and destroying.
Scheduling in process management is across both processes and threads, not strictly processes.
Blocking is a crucial concept in process management.
The kernel still needs to lock critical sections, which involves disabling interrupts and using spinlocks.
Semaphores are a superset that maintains a counter.
“Down” or “P” decrements the counter if it's greater than 0 or blocks the caller.
“Up” or “V” unblocks a process, if available, or increments the counter.
Manage buffer capacity with two semaphores, “remaining” item semaphore (init 0) and “available” slot semaphore (init buffer size).
Producer decrements remaining semaphore before adding to queue, and increments available semaphore when done.
Consumer decrements available semaphore before removing from queue, and increments remaining semaphore when done.
Note that, depending on buffer implementation, additional locking may be necessary to protect the data structure.
Very common in computing to have a producer / consumer program.
“producer” adds data to a fixed size queue at a particular rate.
“consumer” remove and processes data.
Semaphore – more general than mutex; can be used as a counter