0% found this document useful (0 votes)
19 views23 pages

ch2 Operating System Structure

Chapter 2 discusses the essential services provided by an Operating System (OS), including process, memory, file, device management, security, user interface, networking, error handling, and resource allocation. It also covers system calls, their types, and the various structures of operating systems such as simple, layered, microkernel, and modular designs. Additionally, the chapter outlines the design, implementation, generation, and boot processes of operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views23 pages

ch2 Operating System Structure

Chapter 2 discusses the essential services provided by an Operating System (OS), including process, memory, file, device management, security, user interface, networking, error handling, and resource allocation. It also covers system calls, their types, and the various structures of operating systems such as simple, layered, microkernel, and modular designs. Additionally, the chapter outlines the design, implementation, generation, and boot processes of operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Chapter 2: Operating-System Structures

2.1 Operating System Services


 An Operating System (OS) acts as an intermediary between users,
applications, and computer hardware. It provides various services to
ensure smooth operation, resource management, and security.
Here’s a detailed explanation of the key OS services:
1. Process Management
Definition: The OS is responsible for creating, executing, scheduling,
and terminating processes (programs in execution).
🔹 Key Functions:
• Creates and terminates processes.
• Schedules CPU time for multiple processes.
• Synchronizes and communicates between processes.
🔹 Example:
When you open a web browser and a video editing app at the same
time, the OS ensures both processes get CPU time without one
blocking the other.
Operating System Services (Cont.)
2. Memory Management
Definition: The OS manages the computer’s memory (RAM) by allocating and
reallocating space as needed.
🔹 Key Functions:
• Tracks which memory parts are free or in use.
• Allocates memory to running programs.
🔹 Example:
When you run multiple applications, the OS efficiently assigns memory to each so
they don’t interfere with each other.
3. File System Management
Definition: The OS handles files stored on disk drives and provides methods for
creating, reading, writing, and deleting files.
🔹 Key Functions:
• Manages file storage, retrieval, and organization.
• Controls file permissions and access..
🔹 Example:
When you save a document in Word, the OS ensures the file is properly stored
and can be retrieved later.
Operating System Services (Cont.)
4. Device Management
Definition: The OS manages communication between the system and hardware
devices (printers, USB drives, keyboards, etc.).
🔹 Key Functions:
• Detects and installs device drivers.
• Allocates resources to input/output devices.
🔹 Example:
When you plug in a USB drive, the OS automatically detects it and makes it accessible
in the file explorer.
5. Security & Access Control
Definition: The OS protects system data and resources from unauthorized access,
viruses, and cyber threats.
🔹 Key Functions:
• User authentication (passwords, fingerprint scans, etc.).
• File and data encryption.
🔹 Example:
When logging into your computer, the OS checks your password before granting
access. Antivirus software also runs in the background to detect threats.
Operating System Services (Cont.)
6. User Interface (UI) Management
Definition: The OS provides an interface for users to interact with the system,
either through a Graphical User Interface (GUI) or a Command-Line
Interface (CLI).
🔹 Key Functions:
• Displays windows, icons, and menus for easy navigation (GUI).
• Allows direct command execution (CLI).
🔹 Example:
Windows OS uses a GUI where users interact with files
7. Networking
Definition: The OS enables computers to communicate over networks,
including the Internet and local networks.
🔹 Key Functions:
• Manages network connections (Wi-Fi, Ethernet, Bluetooth).
• Controls data transfer between devices.

🔹 Example:
When you connect to Wi-Fi, the OS manages the connection and ensures data is sent
and received properly.
Operating System Services (Cont.)
8. Error Detection & Handling
Definition: The OS constantly monitors system performance and detects
errors to prevent failures.
🔹 Key Functions:
• Logs errors for troubleshooting.
• Automatically fixes minor system issues.
🔹 Example:
If a program crashes, Windows OS shows an error message and might suggest
solutions, like restarting the application.
9. Job Scheduling & Resource Allocation
Definition: The OS schedules and assigns system resources (CPU, memory,
disk, etc.) to different tasks efficiently.
🔹 Key Functions:
• Determines which processes get CPU time.
• Allocates memory and I/O resources to tasks.
🔹 Example:
When multiple applications are running, the OS schedules tasks so that one process
doesn’t use all the CPU while others wait
2.2 System Calls

 Programming interface to the services provided by the OS


 Typically written in a high-level language (C or C++)
 Mostly accessed by programs via a high-level Application
Program Interface (API) rather than direct system call use
 Three most common APIs are Win32 API for Windows, POSIX API
for POSIX-based systems (including virtually all versions of UNIX,
Linux, and Mac OS X), and Java API for the Java virtual machine
(JVM)
 An Application Program Interface (API) is a set of rules and
tools that allows different software applications to communicate
with each other.
System Call Implementation
1.User Application Requests a System Service
•A user program (e.g., a text editor or web browser) needs an OS service, such
as opening a file or allocating memory.
2.System Call Invocation
•The application calls a library function (like open() or read() in C), which
internally invokes a system call.
•The system call is passed to the OS using a system call interface (API such
as POSIX in Unix/Linux).
3.Mode Switch to Kernel Mode
•The CPU switches from user mode to kernel mode, allowing privileged
operations.
•The system call number is stored in a register, indicating which service is being
requested.
4.OS Kernel Processes the Request
•The OS looks up the system call number in a system call table and executes
the corresponding kernel function.
5.Returning to User Mode
•After execution, the OS returns the result (success, failure, or requested data)
to the user program.
•The CPU switches back to user mode to continue execution.
API – System Call – OS Relationship
Standard C Library Example

 C program invoking printf() library call, which calls write() system call
2.2.1.Types of system calls

1.Process control
• Purpose: Manage processes.​
•Examples: fork(), exec(), exit(), wait().​
•Use Case: Creating or terminating processes.

2. File management
• Purpose: handle file operation
• Examples: open(), read(), write(), close().​
• Use Case: Reading from or writing to files.
Types of system calls con’t
3. Device Management
• Purpose: Control hardware devices.​
• Examples: ioctl(), read(), write().​
• Use Case: Interacting with peripherals like printers or disk drives.​
4. Information Maintenance
• Purpose: Retrieve or set system data.​
• Examples: getpid(), getuid(), times().​
• Use Case: Obtaining process IDs or system time.​
5. Communications
• Purpose: Facilitate data exchange between processes.​
• Examples: pipe(), socket(), send(), recv().​
• Use Case: Implementing inter-process communication or networking.
2.3 Operating System Structure
 Since modern Operating systems are large and complex, they must be
engineered carefully to function properly and be modified easily. A common
approach is to partition the task into small components rather than have one
monolithic system.
1. Simple Structure
• Many commercial systems started as small, simple and limited systems and do
not have well-defined structures.
• All OS components (memory management, process management, file
management, etc.) are compiled into a single large kernel.
• The entire OS runs in kernel mode.
• Example: Linux, early UNIX systems.
MS-DOS Layer Structure
2. Layered Structure

 The operating system is divided into a number of layers (levels),


each built on top of lower layers. The bottom layer (layer 0), is the
hardware; the highest (layer N) is the user interface.
 The lowest layer interacts directly with hardware, while higher
layers provide services and interfaces for the user.
 With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers.
 Advantages: simplicity of construction and debugging
 Disadvantages:
 defining the layers
 Less efficient than other types (at each layer, parameters may
be modified, data may need to be passed). Each layer adds
overhead to system calls resulting in system calls that take
longer than do those on a non-layered system.
Layered Operating System
3. Microkernel System Structure

 Removes all non-essential components from the kernel into “user”


space
 Communication takes place between user modules using message
passing
 Benefits:
 Easier to extend a microkernel, all new services are added to
user space and no or little modification to the kernel.
 Easier to port the operating system to new architectures
 More reliable (less code is running in kernel mode)
 More secure
 Detriments:
 Performance overhead of user space to kernel space
communication
4. Modules
 Most modern operating systems implement kernel modules
 Uses object-oriented approach
 Each core component is separate
 The OS is composed of separate modules or components that can be loaded or unloaded as
needed.
 It provides flexibility and maintainability by isolating each function into distinct modules
 Overall, similar to layers but with more flexible
2.4 Operating System Design and Implementation
 Design and Implementation of OS not “solvable”, but some approaches have
proven successful
 Internal structure of different Operating Systems can vary widely
 Operating system (OS) design refers to the architecture, structure, and
functionality of an OS. It defines how the OS manages hardware resources,
provides services, and interacts with applications.
 Key Considerations in OS Design:
 Structure – Choosing between Monolithic, Microkernel, Layered, or Modular
architecture.
 Efficiency – Optimizing CPU, memory, and disk usage.
 Security – Protecting system resources and user data.
 User Interface – Providing CLI (Command Line Interface) or GUI (Graphical
User Interface).
 Concurrency – Handling multiple processes and threads efficiently.
Operating System Design and Implementation (Cont.)
 OS implementation refers to the actual development and coding of the OS,
typically using low-level programming languages like C and Assembly.
 Steps in OS Implementation:
1. Define OS Requirements – Decide on the features and objectives (e.g., multitasking,
security).
2. Select System Architecture – Choose monolithic, microkernel, or hybrid structure.
 Develop Core Components:
 Process Management – Scheduling, process creation/termination.
 Memory Management – Allocating and deallocating memory.
 File System Management – Handling file storage and retrieval.
 Device Management – Managing hardware devices (printers, disks).
 Use System Programming Languages – Typically C/C++ and Assembly for low-
level interactions.
 Testing and Debugging – Ensuring system reliability and performance
2.5. Operating System Generation

 Operating systems are designed to run on any of a class of


machines; the system must be configured for each specific
computer site
 The SYSGEN program is a critical component of the Operating
System Generation process. It is responsible for configuring the
operating system to work with the specific hardware of a computer
system.
 Booting – starting a computer by loading the kernel
 Bootstrap program – code stored in ROM that is able to locate the
kernel, load it into memory, and start its execution
2.6. System Boot

 The system boot refers to the process of starting or restarting a


computer system. It involves loading the operating system (OS)
into memory from storage (like a hard drive or SSD) and preparing
the system to perform tasks.
 Operating system must be made available to hardware so
hardware can start it
 Small piece of code – bootstrap loader, locates the kernel,
loads it into memory, and starts it
 Sometimes two-step process where boot block at fixed
location loads bootstrap loader
 When power initialized on system, execution starts at a fixed
memory location
 Firmware used to hold initial boot code
END OF CHAPTER 2

You might also like