Operating Systems Flashcards
What is an Operating System?
An operating system is a program (OS kernel) that manages different aspects of the operation of the machine and runs the highest privilege in a protected domain.
- Manages processes running on the machine.
- Manages data storage like RAM and file systems
- Manages input/output devices
- Manages networks and communications with other networks.
- Manages the user interface. - Manages security and protection issues.
What is spooling
Where are jobs stored
Input spooling - Placing data into buffers or queues so it can be processed by the system when it is ready to do so.
Output spooling - Sending data from output device to be stored in a buffer, and then the output device can retrieve and process the data from the buffer at its own pace.
It stores these incoming jobs, and output from jobs in the system.
- The secondary storage medium is a disk.
What are time-sharing operating systems?
Allows multiple users or tasks to use a single computer simultaneously. They do this by dividing the CPU into small slices and rapidly switching between users or tasks, giving the illusion of simultaneous operation.
What are real-time operating systems?
Attends jobs / users based on the priority.
What are process control blocks?
What do they contain?
The operating system keeps a record of each process in the system, with a data structure.
- Process ID number
- Pointer
- Process state
- Program counter
- Contents of CPU registers
- Memory management information
- I/O status information
- Accounting information
How do scheduling process work?
Ready queue
- All the processes which are ready to execute.
Device queue:
- All the processes waiting to use a particular device (one queue per device).
Explain system calls.
Systems calls are requests for services to OS kernel, implemented via special instructions e.g., SYSCALL, INT or SVC. These instructions cause interrupts in the CPU.
Instructions called ‘programmer interface’ to OS.
How do system calls (interrupt) work?
The CPU hardware has an ‘interrupt request line’ that can be activated (voltage applied) by system calls or external devices, prompting the OS to respond.
How does OS respond to interrupt?
CPU switches from user to kernel mode, so the control of the CPU is given to the OS.
- Saves the computing context of current process
- Transfers control to a fixed memory location holding an appropriate ‘interrupt-handling routine’.
- When the routine is finished, it restores the context of the interrupted process.
The ‘interrupt vector’ is an array of locations that hold the addresses of these interrupt-handling routines.
How is a Process created?
A process is created by another process: we talk of parent and child processes.
Initial: ‘init’
Give explanation of shapes used in a diagram for life cycle of processes in OS.
- Rounded rectangles are events.
- Rectangles are queues where processes wait.
- Circles are processing resources that serve the events/queues.
How do you implement files - File Systems?
A file is broken into ‘logical blocks’, to make the mapping to disk blocks easier to manage.
What is Disk Allocation Methods?
List and describe each one.
Disk Allocation Methods determine how files are stored on a storage device by specifying how and where data is allocated.
Contiguous Allocation:
File is 100 bytes, it is stored in memory as a contiguous block of 100 bytes.
Linked Allocation:
Each file is a linked list of disk blocks.
File Allocation:
A table is created at the beginning of each partition, with an entry block in the file system. So, each entry points to the next part of the file.
Indexed: Each file has it’s own inode
What are some disadvantages of Contiguous Allocation?
External Fragmentation:
- A situation where the free space is fragmented. The total space is enough for a file but non of the contiguous space.
Internal Fragmentation:
- When the allocated block is larger than what is needed, therefore wasted space.
What are some advantages and disadvantages of Linked Allocation?
- No external fragmentation.
- Only effective for sequential access
- Pointers take up space
- Internal fragmentation (which gets worse the larger your blocks get)
What are some advantages and disadvantages of the File Allocation Table (FAT).
Same as linked allocation, with even more head seeks, in fact. Unless the fat is cached.
What is a Device Driver
A device driver is a special kernel module (software) that controls the operations of a device with the device-specific information (i.e knowledge of the device controller)
In simple terms, a device driver contains information and instructions needed for the operating system to communicate with and control the device. It serves as a bridge between the operating system and device controller.
What is a Device Controller
Device controller is a hardware unit on a device that can know and control a device’s status or behaviour. The CPU communicates with the controller via the device driver.
In simple terms, a device controller is responsible for managing and controlling a specific type of hardware device.
List a few I/O devices, along with their corresponding functionality.
Block Devices:
- Optimize the sequence of the read/write requests in order to improve performance, e.g., I/O scheduling.
Character Devices:
- Handle one character at a time, making them suitable for tasks like reading input from keyboards, mice, and serial ports, where data is processed character-by-character.
- Can support multiple preprocessing facilities: Such as reading line by line (buffering), or handling backspaces.
What are the three I/O models for system calls.
Blocking I/O:
- If a process B issues an I/O system call, it (process B) waits until the I/O is completed.
Non-Blocking I/O:
- If a process issue an I/O system call, it (the process) waits for a fixed (but small) interval, and returns (possibly with some data still untransferred). It keeps trying the system call until I/O is completed.
Asynchronous I/O:
- If a process issues an I/O call, it does not wait for the I/O to be completed, but the OS informs the process with a signal when the I/O is completed.
What does I/O buffering do?
I/O buffering caches frequently used data in memory to reduce secondary storage access and write operations until data access is complete.
What are cooperating processes? and what conditions make a processes ‘cooperative’.
Execution of one process can effect the execution of another, e.g., processes for parallel computing, threads for multi-threading.
Naturally, any processes which share data are cooperating processes.
In terms of cooperating processes, what is the producer / consumer explanation?
The producer generate data and place it in a buffer, while consumers retrieve and process this data.
Briefly explain creating child processes.
What is the value of the parent process and child process?
Parent -> forks (then waits)
Forks -> child process -> exec -> exit
Parent continues
Child: 0
Parent: Child’s PID
What is an ‘address space’ in terms of Parent and Child processes?
It provides a logical and isolated memory environment for a process in the computer’s virtual memory system.
The child process initially inherits the parents address space, but can make changes with no direct impact to the parent’s address space.
Process termination, explain it, and how it occurs.
When a process has executed its last statement, it executes a special function: the exit system call:
- Which may return its status to the parent process.
- All it’s resources are deallocated by the operating system.
Processes can also be terminated by other processes, but:
- You can only kill your own processes (created by the same user).
- Orphan process: A process whose parent terminated (inherited by init).
- Zombie process: One which terminated, but its live parent is NOT waiting for it. Since no process is receiving its exit status, it stays in the process table.
What are process signals?
Signals are important communication channels between the OS kernel and processes. For example, a SIGCHILD signal is sent to a parent when a child process terminates.
Handlers handle signals, if there is no handler, the default is to kill/terminate the process.
What is a Pipe?
A communication channel for connecting one process’ input with another process’ output.
A pipe is used for a typical communication between producer/consumer processes using circular buffer.
Briefly explain shared memory (mmap).
It enables two or more processes to share memory regions, allowing them to exchange data or communicate with each other through it.
It can be achieved by two processes mapping to the same file, or using fork() after mmap().
Private mapping is often used to set up new memory sections (even the child can’t access).
How does private mapping important performance?
Map the file into memory, as memory is more effective than hard-drive access.
So we can just use a pointer to memory, NO system call.
What are threads, describe what they are.
Operating systems frequently support a special kind of processes called a thread to allow more convenient data sharing.
- Threads within a single process use the same information, except they have their own program counter, registers and stack space.
This makes processes more lightweight.