0% found this document useful (0 votes)
10 views41 pages

OS_Unit_1

The document outlines the syllabus for an Operating Systems course, covering topics such as system calls, user and kernel modes, the relationship between APIs and system calls, and the design and implementation of operating systems. It details various types of system calls, their parameters, and the structure of operating systems, including layered architecture and microkernels. Additionally, it discusses security mechanisms and the process of building and booting an operating system.

Uploaded by

nellivarshi26
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)
10 views41 pages

OS_Unit_1

The document outlines the syllabus for an Operating Systems course, covering topics such as system calls, user and kernel modes, the relationship between APIs and system calls, and the design and implementation of operating systems. It details various types of system calls, their parameters, and the structure of operating systems, including layered architecture and microkernels. Additionally, it discusses security mechanisms and the process of building and booting an operating system.

Uploaded by

nellivarshi26
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/ 41

Operating

Systems
Syllabus
UNIT - I
Operating Systems Overview: Introduction,
Operating system functions, Operating systems operations,
Computing environments,
Free and Open-Source Operating Systems
System Structures: Operating System Services, User and
Operating-System Interface, System calls, Types of System
Calls, system programs, Operating system Design and
Implementation, Operating system structure, Building and
Booting an Operating System, Operating system debugging
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

➢ Why use APIs rather than system calls?

➢ System calls provide an interface, to the services made available by an operating


system.

➢ These calls are generally available as routines written in C and C++, to access system
resources.

➢ For a simple command, the operating systems execute thousands of system calls per
second.
System Calls
What’s the difference?
System Call:
The actual low-level request your program makes to the OS kernel to do tasks like open a file,
create a process, read from disk.

API (Application Programming Interface):


A higher-level set of functions provided by the OS (or a language library) that makes it easier
for programmers to use system calls without worrying about the details.

System calls are the raw tools.


APIs are the user-friendly toolbox.

APIs let programmers use the power of system calls in a simple, portable, and safe way —
without worrying about low-level OS details.
System Calls
Kernel Mode:
•When CPU is in kernel mode, the code being executed can access any memory address and
any hardware resource.

•Hence kernel mode is a very privileged and powerful mode.

•If a program crashes in kernel mode, the entire system will be halted.

User Mode
•When CPU is in user mode, the programs don't have direct access to memory and
hardware resources.

•In user mode, if any program crashes, only that particular program is halted.

•The system will be in a safe state.

•Hence, most programs in an OS run in user mode.


System Calls
➢ When a program in user mode requires access to RAM or a hardware resource, it must ask
the kernel to provide access to that resource, through system call.

➢ When a program makes a system call, the mode is switched from user mode to kernel
mode. This is called a context switch.

➢ Then the kernel provides the resource which the program requested.

➢ After that, another context switch happens to change from kernel mode to user mode.
The System Call Interface: How Requests are Made
Library Triggers Syscall

Kernel Executes & Returns

App Calls Library

CPU to Kernel Mode

➢ Applications initiate system calls by utilizing library functions (e.g., C's `open()`, `read()`),
which are wrappers around the actual system call mechanisms.

➢ A specific CPU instruction, such as `syscall` on x86-64 or `int 0x80` on x86, triggers a
transition from user mode to kernel mode.

➢ The kernel maintains a system call table that maps these numbers to their corresponding
internal functions, allowing for efficient dispatch and execution.
System Calls(Example)
Example of a System Call sequence for writing a simple program to read data from one file
and copy them to another file:
•Copy file1.txt to file2.txt,System calls used for this
•Open - input file
•Create - output file
•Error condition,
•Print a message
•Abort system call
•Read - input file
•Write - output file
•Close - i/p, o/p files
•Terminate
System Calls(Examples)
1 File I/O
`open()`, `read()`, `write()`, `close()` - for managing files and data streams.

2 Process Management
`fork()`, `execve()`, `exit()`, `wait()` - for creating, running, and terminating
processes.

3 Memory Management
`mmap()`, `brk()` - for dynamically allocating and mapping memory regions.

4 Networking
`socket()`, `bind()`, `connect()` - for establishing and managing network
communications.

5 System Information
`getpid()`, `gettimeofday()` - for querying system-specific data and time.
System Calls Implementation
➢ The system call interface used to link system calls, which are available in operating
system.

➢ Each system call having its unique number (ID)

➢ Typically, a number associated with each system call


• System-call interface maintains a table indexed according to these numbers

➢ The system call interface invokes intended system call in OS kernel and returns status of
the system call and any return values

➢ The caller need know nothing about how the system call is implemented
• Just needs to obey API and understand what OS will do as a result call

• Most details of OS interface hidden from programmer by API


o Managed by run-time support library (set of functions built into libraries included with
compiler)
API – System Call – OS Relationship
Standard C Library Example
C program invoking printf() library call, which calls write() system call
System Call Parameter Passing
➢ Often, more information is required than simply identity of desired system call
• Exact type and amount of information vary according to OS and call

➢ Three general methods used to pass parameters to the OS

o Simplest: Pass the parameters in registers


• In some cases, may be more parameters than registers

o Parameters stored in a block, or table, in memory, and address of block passed as a


parameter in a register
• This approach taken by Linux and Solaris

o Parameters placed, or pushed, onto the stack by the program and popped off the stack
by the operating system

o Block and stack methods do not limit the number or length of parameters being passed
Parameter Passing via Table
Types of System Calls
• Process control
– end, abort
– load, execute
– create process, terminate process
– get process attributes, set process attributes
– wait for time
– wait event, signal event
– allocate and free memory

• File management
– create file, delete file
– open, close file
– read, write, reposition
– get and set file attributes
Types of System Calls (Cont.)
• Device management
– request device, release device
– read, write, reposition
– get device attributes, set device attributes
– logically attach or detach devices
• Information maintenance
– get time or date, set time or date
– get system data, set system data
– get and set process, file, or device attributes
• Communications
– create, delete communication connection
– send, receive messages
– transfer status information
– attach and detach remote devices
Examples of Windows and Unix System Calls
System Programs
➢ System programs provide a convenient environment for program development and
execution.
They can be divided into:
– File manipulation
– Status information
– File modification
– Programming language support
– Program loading and execution
– Communications
– Application programs

➢System programs provide a convenient environment for program development and


execution.

➢Some of them are simply user interfaces to system calls; others are considerably more
complex
System Programs
➢File management: Create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories

➢Status information:
– Some ask the system for info - date, time, amount of available memory, disk space,
number of users
– Others provide detailed performance, logging, and debugging information
– Typically, these programs format and print the output to the terminal or other output
devices.

➢File modification:
– Text editors to create and modify files
– Special commands to search contents of files or perform transformations of the text
System Programs
➢Programming-language support: Compilers, assemblers, debuggers and
interpreters sometimes provided

➢Program loading and execution: Absolute loaders, relocatable loaders, linkage


editors, and overlay-loaders, debugging systems for higher-level and machine language

➢Communications: Provide the mechanism for creating virtual connections among


processes, users, and computer systems
– Allow users to send messages to one another’s screens, browse web pages, send
electronic-mail messages, log in remotely, transfer files from one machine to another
Security and Protection Mechanisms
Key Security Features in OS Structure

User Authentication: Verification of user identity through passwords, biometrics, or


multi-factor authentication

Access Control: Permission systems that regulate which users or processes can access
specific resources

Encryption: Protection of data through cryptographic techniques both at rest and in transit

Sandboxing: Isolation of applications to prevent malicious or malfunctioning programs from


affecting other parts of the system

Real-World Examples: Windows User Account Control (UAC), Unix file permissions, Apple's
App Store review process, Linux SELinux/AppArmor, BitLocker/FileVault disk encryption
System Programs
In addition to systems programs, most operating systems are supplied with programs that
are useful in solving common problems or performing common operations.
Operating System Design and Implementation
➢ An operating system allows the user application programs to interact with the system
hardware.

➢ Operating system by itself does not provide any function, but it provides an atmosphere in
which different applications and programs can do useful work.

➢ Internal structure of different Operating Systems can vary widely.

Design Goals – Requirements:

➢ The design of the system will be affected by the choice of hardware and the type of
operating system.

➢ The requirements can, however, be divided into two basic groups:


1) User goals
2) System goals
Operating System Design and Implementation
User Goals:
➢ Convenient to use
➢ Easy to learn and to use
➢ Reliable
➢ Safe and Fast

System Goals:
Operating system should be,
➢ Easy to design,
➢ Implement, and Maintain
➢ Flexible, Reliable, Error-free, and Efficient

o Specifying and designing an OS, is highly creative task of software engineering.


Operating System Design and Implementation
Mechanisms and Policies

Policy: What needs to be done?


Example: Interrupt after every 100 seconds

Mechanism: How to do something?


Example: Timer

➢ One important principle is the separation of policy from mechanism.

➢ Policies may change over time and this would lead to changes in mechanism.

➢ So, it is better to have a general mechanism that would require few changes even when a
policy change occurs.
Operating System Design and Implementation
Implementation:
➢ Once an operating system is designed, it must be implemented.

➢ Because operating systems are collections of many programs, written by many people over
a long period of time.

➢ It is difficult to make general statements about how they are implemented.

➢ Early operating systems were written in assembly language. Now, in a higher-level


language such as C, C++.

➢ The lowest levels of the kernel might be assembly language.

➢ An operating system can be written in more than one language.

➢ Higher-level routines might be in C, and system programs might be in C or C++, and


scripting languages like PERL or Python, or in shell scripts.

➢ Linux OS programs written in all of those languages.


Operating System Design and Implementation
The advantages of using higher-level language,
➢ The code can be written faster

➢ It is more compact, and

➢ It is easier to understand and debug.

➢ An operating system is far easier to port-to move to some other hardware— if it is written
in a higher-level language
Operating System Structure
➢ A large and complex modern operating system must be engineered carefully, to function
properly and be modified easily.

➢ Partition the large task into small components, or modules.

➢ Each of these modules should be a well-defined portion of the system, with carefully
defined inputs, outputs, and functions.

➢ There are four different structures based on how components are interconnected into a
kernel
1. Simple Structure
2. Layered Approach
3. Microkernels
4. Modules
Operating System Structure
Simple Structure - MS-DOS Layer Structure
➢ Many operating systems do not have well-defined structures.

➢ This type of OS is small, simple, and limited systems

➢ MS-DOS is an example of such a system.

➢ The interfaces and levels of functionality are not well separated.

➢ Application programs are able to access the basic I/0 routines to write directly to the
display and disk drives.
➢ Hence, MS-DOS vulnerable to malicious programs, causing entire system crashes when
user programs fail.

➢ MS-DOS was also limited by the hardware.

➢ The Intel 8088 for which it was written, provides no dual mode and no hardware
protection.
Operating System Structure
Layered Architecture ➢ 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 main advantage of the layered
approach is simplicity of construction and
debugging and system verification.
➢ Each layer hides the existence of certain
data structures, operations, and hardware
from higher- level layers.
➢ The major difficulty with the layered
approach is appropriately defining the
various layers.
➢ Because a layer can use only lower-level
layers,
Operating System Structure
Layered Architecture Layer Functionality
User Applications: Programs that users
directly interact with
System Utilities: Command shells, file
managers, system monitors
System Call Interface: Provides APIs for
applications to request OS services
Kernel: Core OS services including process
scheduling, memory management, file
systems
Hardware Abstraction Layer: Device-
independent interfaces to hardware
Hardware: Physical computing resources
Operating System Structure
Micro kernels
➢ This method structures the operating system by removing all nonessential components
from the kernel and implementing them as system programs and user-level programs.

➢ The result is a smaller kernel.

➢ There is a little difficulty here, which services should remain in the kernel and which should
be implemented in user space.

➢ Microkernels provide minimal process and memory management, and communication


facility.
Operating System Structure
➢ The main function of the microkernel is to provide communication between the client
program and the various services that are also running in user space.

➢ Communication is provided through message passing.

Advantage
➢ Extending the operating system easier with out modifying the kernel.

➢ Portable from one hardware design to another.

➢ more security and reliability, since most services are running as user— rather than kernel—
processes.

➢ If a service fails, the rest of the operating system remains untouched.

Disadvantage
➢The performance of microkernels can suffer due to increased system-function overhead
Operating System Structure
Modules
➢ Most modern operating systems implement kernel modules
– Uses object-oriented approach
– Each core component is separate
– Each talks to the others over known interfaces
– Each is loadable as needed within the kernel

➢ Overall, similar to layers but with more flexible


➢ The kernel has a set of core components and links in additional services via modules,
either at boot time or during run time.

➢ The kernel to provide core services while other services are implemented dynamically, as
the kernel is running.

➢ CPU scheduling and memory management algorithms directly into the kernel and add
support for different file systems by way of loadable modules.
Operating System Structure
Solaris Modular Approach
Building and Booting an Operating System

➢ Operating systems are designed to run on any of a class of machines; the system must be
configured for each specific computer site.

➢ The system must then be configured or generated for each specific computer site, a
process sometimes known as system generation (SYSGEN) is used for this.

➢ The following kinds of information must be determined by the SYSGEN Program:


o What CPU is to be used?
o How much memory is available?
o What devices are available?
o What operating-system options are desired?
Building and Booting an Operating 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.

➢ When the full bootstrap program has been loaded, it can traverse the file system to find
the operating system kernel, load it into memory, and start its execution.

➢ It is only at this point that the system is said to be RUNNING


Operating-System Debugging
Debugging is finding and fixing errors, or bugs.

➢ Debugging is the activity of finding and fixing errors in a system, both in hardware
and in software.

➢ Performance problems are considered bugs, so debugging can also include performance
tuning, which seeks to improve performance by removing the bottlenecks.

Failure Analysis
➢ If a process fails, most operating systems write the error information to a log file to alert
system operators or users that the problem occurred.

➢ The operating system can also take a core dump, a capture of the memory of the process
and store it in a file for later analysis.

➢ Running programs and core dumps can be used by a debugger, to know about the code
and memory of a process.
Operating-System Debugging
Performance Tuning:

➢ Performance tuning is to improve performance by removing processing bottlenecks.

➢ To identify bottlenecks, we must be able to monitor system performance by producing


trace listings of system behaviour.

➢ All events are logged with their time and parameters and are written to a file.

➢ Then, an analysis program can process the log file to determine system performance and
to identify bottlenecks and inefficiencies.

➢ Traces helps to find errors in operating-system behaviour.


Modern OS Examples, Challenges and Trends
Modern Operating Systems

Windows macOS
Linux
Hybrid kernel architecture, widespread desktop usage, Hybrid kernel (XNU), Unix-based, tightly
Open-source, monolithic kernel, high scalability, powers servers
enterprise integration integrated with Apple hardware
and Android

Current Challenges & Future Trends


Virtualization: Hypervisors, VMs, and containers changing resource utilization
Cloud Computing: Distributed OS architectures, elastic resources, multi- tenancy
Security Challenges: Growing threats, zero-trust models, advanced protection
mechanisms

IoT & Embedded: Lightweight OS designs, real-time processing requirements


Future Developments: Quantum computing OS, AI-optimized kernels, self-healing systems
THANK YOU

You might also like