Operating system (OS) is software that maintains computer system creating an environment to run and control users tasks.
To maintain users tasks operating systems is responsible for:
- planning and allocation of CPU to specific tasks
- controlling and allocation internal memory for run tasks
- providing mechanism to synchronize tasks and communication between them
- hardware support and ensuring simultaneously executed tasks free from the interference of access to the equipment.
A brief description of each point above.
- From operating system, each program is separated process. Each process can be in one with five states.
For remember in which state process is in this time is responsible Process Control Block (PCB). In the typical processor, only one process can be realized at the same time (for example, Hyper-Threading technology invented by Intel is another way). The process scheduler is a part of the operating system that decides which process runs at a certain point in time. There are three types of schedulers:
- Long-term Scheduler – decides which process should be added to the ready queue
- Medium-term Scheduler – decides which process should be swapped and removed from main memory (ready queue)
- Short-term Scheduler – decides which of the ready processes is to be run on CPU.
Dispatcher by context switching is used in order to illusory parallelize work CPU. This is called preemption and consist of saving status and data previous process and adding new process as user CPU. The dispatcher should be as fast as possible. To use switching context are used algorithms as follow:
- First come, first serve
- Earliest deadline first
- Shortest remaining time first
- Fixed priority pre-emptive scheduling
- Round-robin scheduling
- Each program needs some memory to data and program code. The most important in memory management is to provide ways do dynamically allocate portions of memory and free it after finished tasks. The most important way is using a virtual memory that translates memory addresses used by a program to physical addresses (by Memory Management Unit). Virtual memory can increase the size of addresses beyond the amount of RAM using secondary storage. Main storage as seen by process or task appears as a contiguous address space divided to pages or segments. Several issues complicate the implementation, such as external and internal fragmentation. External fragmentation shows gaps between memory used by separate processes. Internal fragmentation shows gaps in pages reserved by a process. Pages have a size (often 4kB) and to eliminate these type gaps process memory request have to be an exact multiple of page size.
To eliminate external fragmentation shall be applied one with three methods:
- First Fit
- Best Fit
- Worst Fit
To eliminate external fragmentation shall be used best to efficiency pages size.
- The section with data, peripheral devices or network connection can be needed by more than on process or thread. This protected section is the critical section or critical region. There are many ways to deal with this problem among others:
- atomic transactions
- synchronization hardware
- I/O devices can be categorized as storage, communications, user-interface, and other. Most popular I/O schemes are:
- Polling – process where the main device waits for an external device to check for its readiness or state
- Interrupt – signal to the processor emitted by hardware or software indicating an event that needs immediate attention
- Direct Memory Access – feature of computer systems that allows hardware subsystems to access main system memory (RAM) without central processing unit (CPU)
Every computer must have an operating system to run others programs or applications. We use it every day. Most popular systems: