CIT 315-Instructional Notes-Update

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

OPERATING SYSTEMS

INSTRUCTIONAL NOTES

 An opera ng system (OS) is a so ware that manages the computer hardware and provides
services for other computer ac vi es. It acts as an intermediary between computer hardware
and so ware, facilita ng communica on and resource management.
o It is a manager that supervises the flow of informa on within the computer system
o It is the first so ware that must be installed before any other so ware is installed
o Examples of OS include: DOS (Disk Opera ng System), UNIX, LINUX, Windows, …
 Key func ons of opera ng systems:
o Resource Management: OS manages various hardware resources such as the central
processing unit (CPU), memory (RAM), storage devices (hard disks, SSDs), input/output
(I/O) devices (keyboard, mouse, monitor, printer), and network interfaces. They allocate
these resources efficiently among mul ple running programs to ensure smooth
opera on.
o Process Management: OS is a gateway to all processes, including loaded/executed
programs or applica ons. It schedules them for execu on, allocates CPU me to them,
and provides mechanisms for inter-process communica on and synchroniza on.
o Memory Management: OS secures the storage for your applica ons and manages them
appropriately, to ensure that each process has enough memory to execute without
interfering with other processes. This involves alloca ng memory when a process
requests it, dealloca ng memory when it's no longer needed, and implemen ng
techniques like virtual memory to efficiently use available physical memory.
o File System Management: OS provide a file system to organize and store data on the
storage devices such as hard disks. File systems manage files, directories, and metadata,
and provide mechanisms for file access, storage, retrieval, and manipula on.
o Device Management: OS control input/output devices such as keyboards, mice,
monitors, printers, and network interfaces. They provide device drivers to communicate
with hardware devices, manage device resources, and handle device interrupts.
o User Interface: OS provide user interfaces to interact with the computer. This can include
command-line interfaces (CLI) where users type commands, graphical user interfaces
(GUI) with windows, icons, menus, and pointers, or other types of interfaces such as
touch-based or voice-based interfaces.
o Security: OS enforce security policies to protect the system and its resources from
unauthorized access, malware, and other threats. This includes user authen ca on,
access control mechanisms, encryp on, and an virus so ware integra on.
o Networking: OS enables communica on between devices, sharing resources, and
accessing services across local and wide area networks.
 Types of OS:
o General-Purpose Opera ng Systems
 Microso Windows: This family of opera ng systems developed by Microso
includes versions like Windows 10, Windows 11, and Windows Server. It is
widely used on desktops, laptops, and servers.
 macOS: Developed by Apple Inc., macOS (formerly Mac OS X) is the opera ng
system used on Apple's Macintosh computers.
 UNIX/Linux: Linux is a Unix-like open-source opera ng system kernel that forms
the basis of many Linux distribu ons such as Ubuntu, Fedora, Debian, CentOS,
and Arch Linux. These distribu ons are used for desktops, servers, embedded
devices, and more.
o Embedded Opera ng Systems:
 Android: Developed by Google, Android is a Linux-based opera ng system
primarily designed for touchscreen mobile devices such as smartphones and
tablets.
 FreeRTOS: A real- me opera ng system kernel designed for embedded devices,
FreeRTOS is used in a wide range of industries, including automo ve, aerospace,
medical devices, and consumer electronics.
 QNX: QNX is a commercial Unix-like real- me opera ng system o en used in
embedded systems, automo ve infotainment systems, industrial automa on,
and medical devices.
 Specialized Opera ng Systems:
o Novell NetWare: A network opera ng system developed by Novell, NetWare was widely
used in the 1980s and 1990s for networking services.
o Google Fuchsia: An open-source capability-based opera ng system being developed by
Google, Fuchsia is designed for modern compu ng devices like smartphones, tablets,
laptops, and IoT devices.
o Red Hat Enterprise Linux (RHEL): A commercial Linux distribu on developed by Red Hat,
RHEL is widely used in enterprise environments for servers and worksta ons.
 Real-Time Opera ng Systems (RTOS):
o VxWorks: Developed by Wind River Systems, VxWorks is a real- me opera ng system
used in applica ons requiring reliability, determinism, and performance, such as
aerospace, defense, automo ve, and industrial control systems.
o RTOS-32: A real- me opera ng system developed by On Time Informa k, RTOS-32 is
designed for x86 embedded systems running Microso Windows.
o eCos: An open-source real- me opera ng system kernel designed for embedded
systems, eCos is used in applica ons such as consumer electronics, industrial
automa on, and telecommunica ons.
 Mobile Opera ng Systems:
o iPhone Opera ng System (iOS)-Developed by Apple Inc., iOS is the opera ng system
used exclusively on Apple's mobile devices such as the iPhone, iPad, and iPod Touch.
o eXtensible Opera ng System (XOS)-an opera ng system designed to support the
development and execu on of so ware applica ons on a wide range of devices and
pla orms.
o Windows Phone (discon nued): Developed by Microso , Windows Phone was the
mobile opera ng system used on smartphones and tablets produced by Microso and
its partners. It has been succeeded by Windows 10 Mobile.
o KaiOS: A mobile opera ng system based on Linux, KaiOS is designed for feature phones
and low-end smartphones, offering smartphone-like features on affordable devices.
 What is a Process?
o A program, so ware, computer task or applica on in execu on is called a process. Put
differently, when a program or task is loaded into memory and executed, it becomes a
process. Each process is unique and has its own memory space, program code, data, and
system resources associated with it.
o Processes are managed by the OS kernel (the core component of an opera ng system,
responsible for managing hardware resources and providing essen al services to
so ware applica ons), which allocates resources, schedules their execu on, and
provides mechanisms for inter-process communica on and synchroniza on.
 Process States
o A process can be in one of several states during its life me. These states include:
 New: The process is being created or ini alized.
 Ready: The process is ready to execute but wai ng for the CPU to be assigned.
 Running: The process is currently being executed on the CPU.
 Blocked (Wai ng): The process is unable to execute because it's wai ng for
some event (e.g., I/O opera on comple on, resource availability).
 Terminated (Exit): The process has completed execu on or has been terminated
by the OS.
o Example 2-state process:
 Running Process: The text editor applica on (e.g., Notepad.exe or Microso
Word) is ac vely running and consuming CPU resources as the user types, edits,
and saves the document. The process represen ng the text editor is in the
"running" state, execu ng code to handle user input, update the graphical user
interface, and perform file opera ons.
 Not running/Idle Process: Meanwhile, if the user pauses typing or performing
any ac on in the text editor, the CPU may become idle momentarily. In this case,
the idle process (e.g., System Idle Process in Windows or Idle task in Linux)
becomes the ac ve process, represen ng the state of the CPU when it's not
execu ng any user-level code. The idle process consumes CPU me while
wai ng for other tasks to be scheduled for execu on.

 Process Control Block (PCB): The OS maintains informa on about each process in a data
structure called the Process Control Block (PCB). The PCB is similar to your i nerary for the day-a
set of ac vi es or ac on tabs that defines your day or that which you must accomplish. Hence,
it contains essen al informa on about the process, including the process ID, program counter,
CPU registers, memory alloca on, scheduling informa on, and accoun ng informa on.
 Process Crea on: Processes are created through system calls provided by the OS. When a
program is executed, the OS creates a new process, allocates resources (such as memory and
CPU me), and ini alizes the process control block.
 Process Scheduling: The OS scheduler decides which process to execute next based on
scheduling algorithms and priori es. The scheduler may use preemp ve or non-preemp ve
scheduling policies to allocate CPU me to processes.
 Context Switching: When the OS switches from execu ng one process to another, it performs a
context switch. This involves saving the state of the currently running process (CPU registers,
program counter, etc.) into its PCB and loading the state of the next process to be executed from
its PCB into the CPU.
 Inter-Process Communica on (IPC): Processes o en need to communicate with each other to
share data, coordinate ac vi es, or synchronize execu on. The OS provides mechanisms for IPC,
such as shared memory, message passing, and synchroniza on primi ves like semaphores and
mutexes.
 Process Termina on: When a process completes its execu on or is terminated by the OS or
another process, the OS deallocates its resources, releases memory, and updates relevant data
structures. The terminated process's PCB is removed, and any associated system resources are
freed up for reuse.
 Scheduling:
o The process of determining the order in which tasks or processes are executed on the
CPU is called scheduling. It's a cri cal aspect of OS design aimed at op mizing system
performance, resource u liza on, and responsiveness.
o Scheduling Policies/Schemes:
 Preemp ve Scheduling: The scheduler can interrupt a running process and
switch to another process based on priori es or me quantum. This allows
higher-priority processes to execute promptly and ensures fairness.
 Non-preemp ve Scheduling: The scheduler allows a process to run un l it
voluntarily gives up the CPU or blocks on an I/O opera on. This policy is simpler
but may lead to lower responsiveness.
 Priority Scheduling: Assigns priori es to processes, and the scheduler selects the
highest-priority process for execu on. This policy ensures that cri cal tasks get
executed first but may lead to starva on of low-priority tasks.
 Round Robin Scheduling: Allocates CPU me to processes in a fixed me
quantum. A er the me quantum elapses, the scheduler preemp vely switches
to the next process in the queue. This policy ensures fairness and prevents any
single process from monopolizing the CPU for an extended period.
 Shortest Job Next (SJN) Scheduling: Selects the process with the shortest
execu on me next. This policy minimizes average wai ng me but may lead to
starva on of long processes.
 Shortest Remaining Time (SRT) Scheduling: Similar to SJN, but the scheduler
preemp vely switches to a shorter job if it arrives and requires less me to
complete than the currently running job.
 First-Come, First-Served (FCFS) Scheduling: Executes processes in the order they
arrive. While simple, this policy may result in long wai ng mes for short jobs if
long jobs arrive first (the convoy effect).
 Q: Is it possible for two processors to execute three processes simultaneously?
A: Yes: The computer accomplishes this through mul processing, which involves running
mul ple processes concurrently on mul ple processors (or cores) within the computer system.
Let’s define the keywords in the ques on:
Two Processors: You have two physical processors (or CPU cores) available in your computer
system. Each processor is capable of execu ng instruc ons independently of the other.
Three Processes: You have three processes that need to be executed simultaneously or
concurrently. These processes could be separate programs, tasks, or threads within a larger
program.
One way the OS deals with such problem is through me mul plexing: While there are only two
processors available, it's s ll possible to execute three processes concurrently through me
mul plexing. The opera ng system can use scheduling algorithms to alternate between the
three processes, allowing each process to take turns execu ng on the available processors.
For instance, if Process 1 is assigned to Processor 1, and Process 2 is assigned to Processor 2, the
OS can allocate me slices to each process. While Process 1 is execu ng on Processor 1 during its
me slice, Process 2 can execute on Processor 2 simultaneously. Then, when Process 1's me
slice expires, the opera ng system can switch to execu ng Process 3 on Processor 1, and so on.

 Context Switching
o A context switch refers to the process of saving and restoring the state of a CPU (Central
Processing Unit) so that it can execute tasks from mul ple processes or threads.
o When a mul tasking opera ng system is running mul ple processes or threads (smallest
units of execu on within a process) concurrently, the CPU needs to switch between
them to allocate processing me fairly and efficiently. A context switch allows the CPU to
temporarily suspend execu on of one process or thread and resume execu on of
another.
o During a context switch, the following steps typically occur:
Save Context: The current state of the CPU, including its register contents, program
counter (a special register in a computer processor that stores the memory address of
the next instruc on to be executed), and other relevant execu on informa on, is saved
into the memory or a data structure known as the Process Control Block (PCB) or Thread
Control Block (TCB).
Load Context: The saved state of the CPU for the next process or thread to be executed
is retrieved from memory or the corresponding PCB/TCB.
Switch Execu on: The CPU updates its state to begin execu ng the instruc ons of the
newly selected process or thread. Context switches are essen al for achieving
mul tasking and concurrency in opera ng systems. They enable the system to efficiently
allocate CPU me among mul ple processes or threads, providing the illusion of
parallelism even on systems with a single CPU core. However, context switches incur
overhead, including the me and resources required to save and restore the CPU state,
so minimizing unnecessary context switches is crucial for op mizing system
performance.
 Interrupts
o An interrupt in an opera ng system is a signal generated by hardware devices or
external events that requires immediate a en on from the CPU. Interrupts allow the
CPU to temporarily suspend its current execu on and switch to a different task or
process to handle the event. This mechanism enables efficient mul tasking and ensures
that cri cal events are handled promptly without was ng CPU cycles.
o Let's illustrate interrupts using a real-world case study: Consider a computer system with
a network interface card (NIC) that receives incoming network packets. When a network
packet arrives at the NIC, it needs to be processed by the opera ng system to determine
its des na on and deliver it to the appropriate applica on. However, the CPU cannot
con nuously poll the NIC to check for incoming packets as it would be inefficient and
wasteful of system resources.
o Instead, the NIC is configured to generate an interrupt signal, known as a network
interrupt, whenever a new packet arrives. When this interrupt occurs, the CPU suspends
its current execu on and transfers control to an interrupt handler, specifically designed
to handle network interrupts. This interrupt handler is commonly referred to as the
network interrupt service rou ne (ISR)

You might also like