Key Concepts in Operating Systems and Process Management

Operating System Functionalities

Operating System (OS) functionalities:

  • Booting
  • Data Security
  • Disk Management
  • Process Management
  • Device Controlling

Scheduling Techniques

Scheduling techniques:

  • First-In, First-Out (FIFO)
  • Earliest Deadline First (EDF)
  • Shortest Job First (SJF)

Scheduling Criteria

Scheduling criteria:

  1. Maximizing CPU utilization: The idea is to maximize the time we have processes in the RUNNING state. The goal is to execute processes efficiently.
  2. Maximizing throughput: The idea is to have the maximum number of completed processes after a prescheduled period of time. The goal is to complete tasks efficiently.

Common Commands and Operations

PUSHD and POPD

  • PUSHD: This command functions similarly to the “change directory” command, but it simultaneously pushes the previous working directory onto a stack. This allows for easy navigation back to previous directories.
  • POPD: To return to the previous directory, use this command. It retrieves the last directory from the stack and changes the current directory to it.

Semaphore Operations

  • SEM_POST: Increases the value of the semaphore by 1. You can always increment the value of a semaphore.
  • SEM_WAIT: Attempts to decrease the value of the semaphore by 1. If the current value is 0, the calling process is blocked until another process performs a SEM_POST on the semaphore.
    Parameter: An identifier for the semaphore.
  • sem_unlink: Removes the link between the file used at the creation stage and the semaphore, rendering the semaphore unusable.

File Content and Manipulation

  • CAT and LESS: These commands display the content of a text file on the standard output.
  • TOUCH FILENAME:
    • If FILENAME does not exist: Creates a new empty file.
    • If FILENAME exists: Updates the file’s timestamp.
  • head -20 FILENAME and tail -20 FILENAME: Display the first or last 20 lines of a file, respectively.

System Calls and Schedulers

  • System call: A mechanism through which a computer program requests a service from the kernel of the operating system on which it is executed.
  • Long-term scheduler: Determines whether to allow the creation of a new process on the system.
  • Short-term scheduler: Decides which process to move from the ready state to the running state.

Thread Termination

Ways to terminate a thread’s execution:

  • The thread itself calls the function pthread_exit().
  • The thread completes execution with a return call.

I/O-Bound Processes

I/O-bound process: A process or program that involves a significant number of I/O operations. Consequently, the process will frequently transition to the waiting state.

Operating System Definition

Operating System: A collection of programs that manage a computational system, facilitating communication between software and hardware.

Inter-Process Communication (IPC)

  • Pipes: To share information between pipes, two pipes are required because information needs to be sent bidirectionally between two processes.
  • Sockets: One socket is sufficient because sockets are inherently bidirectional.
  • Shared memory segments: Two semaphores are needed: one to inform Process A that information has been written by Process B, and another for the opposite direction.

Process States

List of process states: NEW -> READY, READY -> RUNNING, RUNNING -> WAITING, RUNNING -> READY, RUNNING -> TERMINATED, WAITING -> READY.

Process Control Block (PCB)

Information found in a PCB: STACK, HEAP, DATA, PID (Process ID), PPID (Parent Process ID).

Network Programming Function Calls

List of function calls: A and B. If SOCK_DGRAM is used, the protocol must be IPPROTO_UDP. If SOCK_STREAM is used, the protocol must be IPPROTO_TCP.

  • getpid(): Returns the PID (an integer) of the current process.
  • getppid(): Returns the PID of the parent process of the current process.
  • htons(): Converts a short integer value from host endianness to network endianness (always big-endian).
  • ntohl(): Converts a long integer value from network endianness (always big-endian) to host endianness (system-dependent).
  • memset: Sets a specified number of memory positions to the same value.
    • The pointer to the beginning of the memory to be set.
    • The value to be used as the filling parameter.
    • The number of bytes to be filled.

Scheduler and Dispatcher

  • Scheduler: Selects the next process to be executed.
  • Dispatcher: Moves the context information for the next process from its PCB to the foreground and moves the context information of the current process to its PCB in the background.

Process Creation

Methods to create a clone/new process: fork(), system(), and the set of exec() system calls.