Operating Systems Fundamentals
Process Management
What is a process and how is it different from a program?
- A process is an instance of a program in execution. It includes the program code and its current activity. A program is a static set of instructions, while a process is a dynamic entity with a life cycle.
What are the different states of a process?
- New: The process is being created.
- Ready: The process is waiting to be assigned to the CPU.
- Running: Instructions are being executed.
- Waiting: The process is waiting for some event to occur.
- Terminated: The process has finished execution.
What is context switching?
- Context switching is the process of storing the state of a currently running process and restoring the state of a different process. This allows multiple processes to share a single CPU.
Scheduling
Explain different CPU scheduling algorithms.
- First-Come, First-Served (FCFS): Executes processes in the order they arrive.
- Shortest Job Next (SJN): Selects the process with the smallest execution time.
- Round Robin (RR): Each process gets a fixed time slice in cyclic order.
- Priority Scheduling: Processes are selected based on priority.
- Multilevel Queue Scheduling: Processes are divided into different queues based on priority or type.
What is a time quantum in Round Robin scheduling?
- A time quantum is a fixed time period during which a process is allowed to run in Round Robin scheduling.
Memory Management
What is virtual memory?
- Virtual memory is a memory management technique that gives an application the impression it has contiguous working memory, while in reality, it may be physically fragmented and may even overflow onto disk storage.
Explain paging and segmentation.
- Paging: Divides memory into fixed-sized blocks called pages. Each process is divided into pages, which are loaded into memory frames.
- Segmentation: Divides memory into variable-sized segments, each representing a logical unit of the process, such as a function or a data structure.
What is a page fault?
- A page fault occurs when a program tries to access a page that is not currently in memory, causing the operating system to fetch the page from disk.
Deadlock
What are the necessary conditions for a deadlock to occur?
- Mutual Exclusion: At least one resource must be held in a non-sharable mode.
- Hold and Wait: A process holding at least one resource is waiting for additional resources held by other processes.
- No Preemption: Resources cannot be preempted.
- Circular Wait: There exists a set of processes such that each process is waiting for a resource held by the next process in the set.
How can deadlock be prevented?
- Ensure at least one of the necessary conditions for deadlock cannot hold.
- Methods include resource allocation graphs, preemption, and ordering resources.
File Systems
What is an inode in a file system?
- An inode is a data structure on a filesystem that stores information about a file or a directory, such as its size, owner, permissions, and the disk block locations.
Explain different file allocation methods.
- Contiguous Allocation: Each file occupies a set of contiguous blocks.
- Linked Allocation: Each file is a linked list of disk blocks.
- Indexed Allocation: An index block contains pointers to the actual data blocks of the file.
I/O Systems
What is an interrupt?
- An interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention.
Explain the concept of DMA (Direct Memory Access).
- DMA allows hardware subsystems to access the main system memory independently of the CPU, improving the efficiency of data transfers.
Miscellaneous
What is a kernel and what are its functions?
- The kernel is the core part of an operating system, managing system resources and communication between hardware and software components. Functions include process management, memory management, device management, and system calls.
What is a system call?
- A system call is a programmatic way in which a computer program requests a service from the kernel of the operating system. Examples include file manipulation (open, read, write), process control (fork, exec), and communication (pipe, socket).
Explain the difference between monolithic and microkernel architectures.
- Monolithic Kernel: The entire operating system works in the kernel space, providing high performance.
- Microkernel: Only essential functions run in the kernel space, with other services running in user space, offering better modularity and security.
What are the differences between multitasking, multiprocessing, and multithreading?
- Multitasking: Running multiple tasks (processes) simultaneously.
- Multiprocessing: Using two or more CPUs within a single computer system.
- Multithreading: Running multiple threads within a single process.
