Operating Systems Flashcards
(37 cards)
Operating System Structures
- Monolithic
- Layered
- Microkernel
- Modular
Monolithic Structure
All devices are implemented
by a large kernel. Any new feature is added to the kernel. “Everything is connected to everything”.
Pros and Cons of the Monolithic Structure
Communications within the kernel is fast. However, the OS may be difficult to understand, difficult to modify and less secure.
Layered Structure
An Operating System with a layered structure organizes its services into distinct layers. Each layer can only communicate with adjacent layers.
Pros and Cons of the Layered Structure
The OS is easy to debug. Development can easily be organized into separate units. However, performance may be poor since access to a specific service often requires traversal through multiple layers.
Microkernel Structure
An OS with a microkernel structure has services implemented by servers, and a small kernel delivering messages between them.
Pros and Cons of the Microkernel Structure
The OS is secure and reliable. Performance may be poor due to increased communication overhead.
Modular Structure
The operating system begins with a small kernel and adds or removes additional modules as needed
Pros and Cons of the Modular Structure
The OS is fast since unnecessary services do not need to be loaded and since it allows for direct communication between modules. However, as the number of loaded module increases, the OS begins to resemble a monolithic structure.
Process Control Blocks
Process Number
Process State
Process address space
Process I/O
Each process is represented by a process control block (PCB). The process control block is stored in memory (or on disk).
How does Context Switch work (A,B)
Stop running process A and start process B:
1. change the process schedule state of process A
2. save the context of process A
3. load the context of process B
change the process scheduling state of process B
Context Switches (ctd)
- A context switch is pure overhead
The time it takes depends on several factors, including the number of registers that must be copied.
Sections of Process Address Space
A process addresses space has four sections:
1. A stack for temporary data
2. A heap for dynamically-allocated data
3. A data section for static data
a. size is constant, so data can be changes, but not in the size bigger than initial
a text section for program code
The Heap
In the heap, blocks of memory are allocated and removed in an arbitrary order. The heap is used for variables that need to persist beyond the scope of a single function or need a flexible amount of memory.
Process Spawning
A process is created at the request of a different process. In Linux there are four system calls for process spawning.
fork, exec, wait, exit
Interprocess Communication can be implemented using? (0/2]
Interprocess communication may be implemented using either:
1. shared memory
message passing
Shared Memory
Interprocess communication by shared memory involves processes writing data to/reading data from an agreed area of memory.
Message Passing
Interprocess communication by message passing involves processes sending messages to/receiving messages from an agreed mailbox.
Shared Memory vs Message Passing
Message passing requires regular system calls, while shared memory only requires system calls to set up the shared memory space. As a result, shared memory is generally more efficient for large data transfers, whereas message passing is better suited for smaller data exchanges.
Controller Registers
The CPU communicates with the controller by reading and writing to the controller’s registers. (data in, data out, status, control)
Port-based I/O vs Memory-mapped I/O
The CPU can access the controller registers using special instructions (port-based I/O) or standard memory instructions (memory-mapped I/O). Memory-mapped I/O is today much more common than port-based I/O.