Operating System Fundamentals: Processes, Scheduling, and Concurrency

1. Leading Operating System Functions

Process Management

Management of Primary Memory

2. Definitions and Examples

  • Program: A sequence of instructions a computer can interpret and execute.
  • Process: A set of activities or events performed to follow a specific purpose.
  • Parent Process: Maintains control over its descendants and can terminate any of its child processes.
  • Child Process: Inherits resources from the parent process unless explicitly acquired by the parent.
  • Process vs. Thread: A process has its own memory area and runs concurrently with other processes. Threads within a process share the same memory space.

3. (Content missing)

4. What is a Script and its Uses?

A script is a set of instructions that automate tasks and create small utilities. It is commonly used for UNIX system administration.

5. Parent and Child Processes

  • Fork: Creates a new process by generating a copy of itself. This copy acts as a child process to the parent. The resulting processes are identical but have different Process IDs (PIDs).
  • Execv: Provides an array of character pointers to commands, ending with a null pointer (0). The first argument should point to the name of the file to be executed.
  • Q-System: A system where ‘q’ represents a function call to commands or functions.

6. Process Monitoring and Resource Management

Older systems require robust process monitoring and resource management capabilities. This involves managing:

  • Processes Table
  • Memory Table
  • File Table

7. Process Control Block (PCB)

The Process Control Block (PCB) stores essential information about a particular process, including:

  • Process ID (PID)
  • Parent Process ID (PPID)
  • Process State
  • CPU Register Values
  • Data Owner
  • Stack Memory
  • Permissions
  • Program

8. The Boot Process

The boot process involves a program loaded in the Read-Only Memory (ROM) that initiates the system startup. This “ROM starter” is independent and fades into the boot ROM.

9. Scheduling Algorithm Favoring Short Processes

An algorithm that favors processes consuming the least amount of processor time in the recent past benefits I/O-bound processes. However, a disadvantage is that CPU-bound processes might be postponed indefinitely.

10. Scheduling Algorithm Differences

  • FCFS (First-Come, First-Served): Simple but not conducive to minimizing turnaround time.
  • RR (Round Robin): Uses a time quantum (TQ).
  • SJF (Shortest Job First) and SRTF (Shortest Remaining Time First): Minimize process time based on the (remaining) burst length.
  • Multilevel Queues with Feedback: Processes using excessive CPU time are moved to lower priority queues, ensuring short processes remain in high-priority queues.

11. Evaluating Scheduling Algorithm Efficiency

The efficiency of scheduling algorithms can be evaluated using:

  1. CPU Utilization
  2. Minimum Timeout
  3. Turnaround Time (Minimize)

12. Scheduling Algorithms: Operation, Advantages, and Disadvantages

  • FCFS:
    • Advantage: Simple to implement.
    • Disadvantage: Not guaranteed to minimize turnaround time; long processes can block short ones.
  • SJF:
    • Advantage: Best performance in terms of average turnaround time.
    • Disadvantage: Requires knowing the exact burst time in advance; not preemptive.
  • Priority Scheduling:
    • Advantage: Allows important processes to be executed first.
    • Disadvantage: Low-priority processes may suffer from starvation; requires a mechanism to prevent indefinite waiting (e.g., aging).
  • RR:
    • Advantage: Provides fairness in shared systems; each process gets a time slice.
    • Disadvantage: Performance depends on the quantum size; context switching overhead can be significant.
  • Multilevel Queue Scheduling:
    • Advantage: Allows for different scheduling policies for different types of processes.
    • Disadvantage: Requires careful configuration to prevent starvation and ensure fairness.

13. Concurrency Problems

During process execution, several concurrency problems can occur:

  • Mutual Exclusion: Ensuring that only one process accesses a shared resource at a time.
  • Deadlock: A situation where two or more processes are blocked indefinitely, waiting for each other.
  • Starvation: A situation where a process is indefinitely delayed from being executed.

14. Thread Identification and Creation

Minimally, the following functions are necessary to identify and create a thread:

  • pthread_create: Creates a new thread.
  • Functions to identify a thread.
  • Mechanisms to ensure the main process waits for thread completion.