SlideShare a Scribd company logo
OPERATING SYSTEM
Prepared by
Ms. S. SHANMUGA PRIYA
Senior Assistant Professor
Department of CSE
New Horizon College of Engineering
Bangalore
Karnataka.
OPERATING SYSTEM SERVICES
SAMPLE QUESTION
List out the different services that an OS provides.
Explain any two. (6 Marks)
OPERATING SYSTEM SERVICES
OS SERVICES
SYSTEM PROGRAMS
For ensuring efficiency of OS
User Interface
Program Execution
I/O Operations
File-System Manipulation
Communication
Error Detection
Resource Allocation
Accounting
Protection and Security
USERS
A View of Operating System Services
SYSTEM CALLS
SAMPLE QUESTIONS
• What are system calls? Explain the different categories of
the system calls. (10 Marks)
• What are system calls? With examples explain different
categories of system calls. (7 Marks)
• With examples, explain how system calls handle user
applications. (6 Marks)
• Explain any two types of system calls. (5 Marks)
• Describe the various types of system calls. (7 Marks - Make
up exam Jan 2018)
• System Calls aka Kernel Call
– System calls provide a means for user or
application programs to call upon the services of
the operating system.
– Generally written in C or C++, although some are
written in assembly for optimal performance.
EXAMPLE OF SYSTEM CALL
TASK:
Write a simple C program to
copy the content of one file to
another file.
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
STEPS INVOLVED
• Acquire input file name
• Write prompt to screen
• Accept input
• Acquire output file name
• Write prompt to screen
• Accept input
• Open the input file
• If file doesn't exist, abort
• Create output file
• If file exists
• Loop
• Read from input file
• Write to output file
• Until read fails
• Close output file
• Write completion message to screen
• Terminate normally
STEPS INVOLVED
• Acquire input file name
• Write prompt to screen
• Accept input
• Acquire output file name
• Write prompt to screen
• Accept input
• Open the input file
• If file doesn't exist, abort
• Create output file
• If file exists,
• Loop
• Read from input file
• Write to output file
• Until read fails
• Close output file
• Write completion message to screen
• Terminate normally
printf("n enter source file name");
gets(fname1);
printf("n enter destin file name");
gets(fname2);
fp1=fopen(fname1,"r");
fp2=fopen(fname2,"w");
if(fp1==NULL||fp2==NULL)
{
printf("unable to open");
exit(0);
}
do
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
while(ch!=EOF);
fcloseall();
getch();
}
SYSTEM CALL INVOLVED???
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp1,*fp2;
char ch, fname1[20], fname2[20];
printf("n enter source file name");
gets(fname1);
printf("n enter source file name");
gets(fname2);
fp1=fopen(fname1,"r");
fp2=fopen(fname2,"w");
if(fp1==NULL||fp2==NULL)
{
printf("unable to open");
exit(0);
}
do
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
while(ch!=EOF);
fcloseall();
getch();
}
Example of System Calls
• Frequently, systems execute thousands of
system calls per second.
• Most programmers never see this level of
detail, however.
• Typically, application developers design
programs according to an Application
Programming Interface (API).
• A system call is a way for programs to interact with the
operating system.
• A computer program makes a system call when it makes a
request to the operating system’s kernel.
• System call provides the services of the operating system to
the user programs via Application Program Interface(API).
• It provides an interface between a process and operating
system
Application Programming Interface (API)
• API specifies a set of functions that are available to
an application programmer, including the parameters
that are passed to each function and the return values
the programmer can expect.
(OR)
• System of tools and resources in an OS enabling
developers to create software applications.
• As the operating system encounters these API
functions, it takes the desired action, so the
programmer does not need to know the details of
controlling the hardware.
SYSTEM CALLS Cont…
• Typically, application developers design programs according
to an Application Programming Interface (API).
• Mostly accessed by programs via a high-level Application
Program Interface (API) rather than direct system call use.
• A programmer accesses an API via a library of code provided
by the operating system.
• In the case of UNIX and Linux for programs written in the C
language, the library is called libc.
• System call provides the services of the operating system to
the user programs via Application Program Interface(API)
• Each operating system has its own name for each system
call.
• Three most common APIs are:
- Win32 API for Windows
- POSIX API (Portable Operating System Interface) for
POSIX-based systems (all versions of UNIX, Linux, and
Mac OS X)
- Java API for the Java Virtual Machine (JVM)
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
SYSTEM CALLS Cont…
• Behind the scenes, the functions that make up
an API typically invoke the actual system
calls on behalf of the application programmer.
• For example, the Windows function
CreateProcess( ) (which unsurprisingly is
used to create a new process) actually invokes
the NTCreateProcess( ) system call in the
Windows kernel.
SYSTEM CALLS Cont…
• Why would an application programmer prefer
programming according to an API rather than
invoking actual system calls?
• Program Portability
–Programmer designing a program using an
API can expect her program to compile and
run on any system that supports the same
API
Example of Standard API
• Consider the ReadFile() function
• Win32 API—a function for reading from a file
• A description of the parameters passed to ReadFile()
– HANDLE file—the file to be read
– LPVOID buffer—a buffer where the data will be read into and written from
– DWORD bytesToRead—the number of bytes to be read into the buffer
– LPDWORD bytesRead—the number of bytes read during the last read
– LPOVERLAPPED ovl—indicates if overlapped I/O is being used
SYSTEM CALL IMPEMENTATION
• For most programming languages, the run-time support system
(a set of functions built into libraries included with a compiler)
provides a system call interface that serves as the link to
system calls made available by the operating system.
• The system-call interface intercepts function calls in the API
and invokes the necessary system calls within the operating
system.
• Typically, a number is associated with each system call, and
the system-call interface maintains a table indexed
according to these numbers.
SYSTEM CALL IMPEMENTATION Cont…
• 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
• Managed by run-time support library (set of functions built into
libraries included with compiler)
API – System Call – OS Relationship
(During Run-Time)
SYSTEM CALL TABLE
maintained by
system call interface
Invokes the necessary
System call in the OS
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
METHOD 1
Pass the parameters in registers
Advantage
- Simplest Method
Disadvantage
- In some cases, may be more parameters than
registers
METHOD 2
Block or table in memory
Parameters stored in a
block, or table, in memory, and
address of block passed as a
parameter in a register
•Advantage
–Do not limit the number or
length of parameters being
passed
•Disadvantage
–Uses user memory space This approach taken by Linux
and Solaris
PARAMETER PASSING VIA TABLE
METHOD 3
– Use stack
– Parameters placed, or pushed, onto the stack by
the program and popped off the stack by the
operating system
– Advantage
• Do not limit the number or length of parameters
being passed
TYPES OF SYSTEM CALLS
System calls can be grouped into 6 major
categories:
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communications
• Protection
◦ 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
PROCESS CONTROL
includes
the job’s priority, its
maximum allowable
execution time, so on…
Module 3
◦ create file, delete file
◦ open, close
◦ read, write, reposition
◦ get file attributes, set file attributes
FILE MANAGEMENT
File Attributes
Name,
File Type,
Protection Codes,
Accounting Information, and so on
Rewind or Skip to the
end of the file
◦ request device, release device
◦ read, write, reposition
◦ get device attributes, set device attributes
◦ logically attach or detach devices
DEVICE MANAGEMENT
Main Memory
Disk Drives,
Access to Files, so on…
INFORMATION MAINTENANCE
◦ get time or date, set time or date
◦ get system data, set system data
◦ get process, file, or device attributes
◦ set process, file, or device attributes
COMMUNICATIONS
◦ create, delete communication connection
◦ send, receive messages
◦ transfer status information
◦ attach or detach remote devices
• Protection was a concern only on multiprogrammed
computer systems with several users.
• System Calls providing protection include:
– set permission( )
– get permission( )
– allow user( )
– deny user( )
PROTECTION
Manipulate permission setting of
resources such as files and disks
Specify whether particular users can
or cannot be allowed to access
certain resources
Examples of Windows and Unix System Calls
OPERATING-SYSTEM DESIGN AND
IMPLEMENTATION
SAMPLE QUESTION
• Discuss briefly the various aspects to be
considered while operating system is designed
and implemented.
OPERATING SYSTEM DESIGN AND IMPLEMENTATION
• Design and Implementation of OS not “solvable”, but some
approaches have proven successful
i) DESIGN GOALS
• PROBLEMS:
• Defining goals and specifications
• Varying internal structure of different Operating Systems
• Affected by choice of hardware, type of system
• Harder to specify requirements
Batch, Time Sharing, Single User,
Multi-User, Distributed, Real Time, or
General Purpose
OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont…
REQUIREMENTS
USER GOALS SYSTEM GOALS
OS should be convenient to
- use,
- easy to learn,
- reliable,
- safe, and
- fast
OS should be
- easy to design,
- implement,
- maintain,
- flexible,
- reliable,
- error-free, and
- efficient
There is no unique solution to the problem of
defining OS requirements
ii) Mechanisms and Policies
• Important principle to separate
Policy : What will be done?
Mechanism : How to do it?
• For example,
– Timer
– Policy : How long the timer to be set for a
particular user is a policy decision?
- Mechanism : Ensuring CPU protection
likely to change across
places or over time
Require a change in
the underlying
mechanism
OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont…
Implementation
• Traditionally OSes were written in assembly language. This
provided direct control over hardware-related issues, but
inextricably tied a particular OS to a particular HW platform.
• Recent advances in compiler efficiencies mean that most
modern OSes are written in C, or more recently, C++.
• Operating systems may be developed using emulators of the
target hardware, particularly if the real hardware is
unavailable (e.g. not built yet), or not a suitable platform for
development, (e.g. smart phones, game consoles, or other
similar devices.)
OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont…
OPERATING-SYSTEM
STRUCTURE
SAMPLE QUESTIONS
List out the various operating system structures.
Explain them with suitable diagrams.
Explain the advantage of layered approach with
a neat diagram. (6 Marks)
Explain the layered approach to the structuring
of an operating system along with the relevant
diagram. (10 Marks)
• System as large and complex must be carefully
engineered
• Common Approach
– Partition the task into small components rather
than having one monolithic system
• Design each modules with careful
– Inputs
– Outputs
– Functions
OPERATING SYSTEM STRUCTURE
OPERATING SYSTEM STRUCTURE Cont…
• Ways to interconnect components
i) Simple Structure
ii) Layered Approach
iii) Microkernels
iv) Modules
v) Hybrid Systems
 Mac OS X
 iOS
Android
OPERATING SYSTEM STRUCTURE Cont…
i) Simple Structure (Monolithic)
- A monolithic kernel is an operating system
architecture where the entire operating system is
working in kernel space
-Commercial system do not have well-defined structures
- Such systems are started as small, simple, and limited
and then grew beyond their original scope
Example: MS-DOS
–Written by a few programmers in a relatively
short amount of time, without the benefit of
modern software engineering techniques
–It does not break the system into subsystems, and
has no distinction between user and kernel modes,
allowing all programs direct access to the underlying
hardware.
OPERATING SYSTEM STRUCTURE Cont…
MS-DOS Structure
Interfaces and functionalities
are not well separated
- Ex: Application program
are able to directly access
I/O routines to write
directly to the display and
disk drives
- Problem : May leave MS-
DOS vulnerable to
malicious programs,
cause system to crash
- Limited by hardware
functionality
User directly
access the
hardwares
A program (Terminate and Stay Resident) that remains in memory at all times
for immediate availability. Ex: Quick pop up of calculator, calendar
A device driver is a program that controls a particular type of device that is
attached to your computer.
OPERATING SYSTEM STRUCTURE Cont…
Traditional UNIX System Structure
Below the
system-call
interface
and
Above the
physical
hardware
NOTE: Still see evidence of this simple, monolithic structure
in the UNIX, Linux, and Windows operating systems
OPERATING SYSTEM STRUCTURE Cont…
UNIX
• UNIX
– limited by hardware functionality, the original UNIX
operating system had limited structuring.
• The UNIX OS consists of two separable parts
– System Programs
– The Kernel
• Provides the
• File System,
• CPU Scheduling,
• Memory Management, and
• Other Operating-System Functions
• Advantage : Less communication overhead
• Disadvantage: Kernel becomes large and hard to manage
No separable parts
in MS-DOS
A large number of
functions for one level
• Pros
– Speed
– Simplicity of design
• Cons
– Potential stability issues
– Can become huge - Linux 2.6 has 7.0 million lines of code
and Windows over 30 million!
– Potentially difficult to maintain
• Examples
– Traditional Unix kernels
– Linux
– MS-DOS, Windows 9x
– Mac OS versions below 8.6
ii) LAYERED APPROACH
• OS broken into pieces of smaller and
appropriate one for supporting hardware's
• Advantage:
– OS will have much greater control over the
computer and other applications
– Implementers have freedom to change inner
workings of systems
– Information hiding is important, and can be
implemented
OPERATING SYSTEM STRUCTURE Cont…
• How to make a system modular?
• One Method is follow Layered Approach
• What is a layered approach?
– The operating system is broken into a number of
layers (levels).
– Each built on top of lower layers
– Bottom Layer (layer 0)  Hardware
– Highest Layer (layer N)  User Interface
OPERATING SYSTEM STRUCTURE Cont…
Layered Operating System
Layer 5 : User Program
Layer 4 : Buffering for Input and Output Devices
Layer 3 : Operator-Console Device Driver
Layer 2 : Memory Management
Layer 1 : CPU Scheduling
Layer 0 : Hardware
Ex : Microsoft Windows NT OS
Each module provide a set of
functions that other module can
call
Interface functions at any
particular level can invoke services
provided by lower layers but not
the other way around
• Advantages
– Simplicity of construction and debugging
– Layers are selected such that each uses functions
(operations) and services of only lower-level layers
– Layers know only what they must do, hence
hides the existence of data structures, operations
and hardware from higher-level
OPERATING SYSTEM STRUCTURE Cont…
Layered Approach
• Disadvantages
– Difficult in defining various layer with appropriate
functionalities
– Ex: Device driver for the backing store must be at
lower level than the memory management
routines, because, memory managements requires
the ability to use the backing stores
– Less efficient, due to multiple level leads to
communication overhead.
OPERATING SYSTEM STRUCTURE Cont…
Layered Approach
OPERATING-SYSTEM STRUCTURE Cont…
iii) MICROKERNELS
• Kernel – If it expands, difficult to manage
• Designed in 1980s, researchers at Carnegie Mellon
University developed an operating system called Mach that
modularized the kernel using the microkernel approach.
• Designing Approach:
– Removed all nonessential components from kernel and
implemented them as system and user-level program
– Result : Small kernel
– Example: QNX, a real-time OS for Embedded Systems
MONOLITHIC KERNEL MICRO KERNEL
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
• Functions Provided by Kernel:
– Provides communication facility between the client
program and various services running in user space
– takes place between user modules
using message passing
OPERATING-SYSTEM STRUCTURE Cont…
MICROKERNEL
Communication
OPERATING-SYSTEM STRUCTURES Cont…
MICROKERNEL
iii) Microkernel
• Benefits:
– Easier to extend a microkernel
– Easier to port the operating system to new architectures
– More reliable (less code is running in kernel mode)
– Stability
• Detriments:
– Additional context switches are usually required
– Performance overhead of user space to kernel space
communication
– Slow Inter Process Communication can result in poor
performance
• Examples
–AmigaOS
–Amoeba
–Mach
–Minix
–MorphOS
–L4
–QNX
OPERATING-SYSTEM STRUCTURES Cont…
MODULES
iv) 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 kernel modules as needed within
the kernel
• Overall, similar to layers but with more
flexible
During boot time or run time
Solaris Modular Approach
Solaris OS Core Kernel with 7 types of loadable kernel modules
• Modules are similar to layers in that each subsystem
has clearly defined tasks and interfaces, but any
module is free to contact any other module,
eliminating the problems of going through multiple
intermediary layers,
• The kernel is relatively small in this architecture,
similar to microkernels, but the kernel does not
have to implement message passing since modules
are free to contact each other directly.
• In practice, very few operating systems adopt a single, strictly
defined structure.
• Instead, they combine different structures, resulting in hybrid
systems that address performance, security, and usability
issues.
• For example,
– Linux and Solaris are monolithic, and also modular
– Windows is
• largely monolithic as well, but it retains some behavior
typical of microkernel system
• support for dynamically loadable kernel modules
(Windows 7)
HYBRID SYSTEM
OS have single address space Functionalities can be added
dynamically
HYBRID SYSTEM – MAC OS X
• Mac OS X is a layered system Top layer includes
user interface,
application
environments and
services
Specifies an API for
the Objective - C
programming
language, which is
used for writing Mac
OS X applications
Apple's native object-
oriented application
programming interface (API)
for their operating
system MacOS
An extensible multimedia
framework developed by Apple Inc., capable
of handling various formats of digital video,
picture, sound, panoramic images,
and interactivity.
AQUA THEMES
FOLDER VIEW
Dashboard View in Mac OS X
• iOS is a
– mobile operating system designed by Apple to
run its smartphone iPhone, as well as its tablet
computer, the iPad.
• iOS is structured on the Mac OS X operating
system, with added functionality pertinent to
mobile devices, but does not directly run Mac
OS X applications.
HYBRID SYSTEM – iOS
Hardware
Cocoa Touch is an API for Objective-C that
provides several frameworks for developing
applications that run on iOS devices
NOTE: Cocoa Touch provides support
for hardware features unique to mobile
devices, such as touch screens.
The media services layer provides
services for graphics, audio, and video
The core services layer
provides a variety of features,
including support for cloud
computing and databases.
The bottom layer represents the core
operating system, which is based on the
kernel environmentLAYERED STRUCTURE
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES

More Related Content

PPTX
System calls
PPT
Operating system services 9
PPT
System call
PPTX
Ch1-Operating System Concepts
PDF
Operating systems system structures
PDF
Complete-Mini-Project-Report
PPTX
Basics of JAVA programming
PPTX
Binary Tree Traversal
System calls
Operating system services 9
System call
Ch1-Operating System Concepts
Operating systems system structures
Complete-Mini-Project-Report
Basics of JAVA programming
Binary Tree Traversal

What's hot (20)

PPT
Introduction to System Calls
PDF
Process scheduling (CPU Scheduling)
PPTX
MULTILEVEL QUEUE SCHEDULING
PPT
Memory Management in OS
PPTX
Deadlock ppt
PPT
Mutual exclusion and sync
PPTX
Semophores and it's types
PPTX
Operating system components
PPT
Scheduling algorithms
PPTX
Os unit 3 , process management
PPT
Memory management
PPTX
Computer architecture virtual memory
PPS
Virtual memory
PPTX
SCHEDULING ALGORITHMS
PPT
Operating Systems Process Scheduling Algorithms
PPTX
Swapping | Computer Science
PPTX
Memory management ppt
PPT
Basic MIPS implementation
Introduction to System Calls
Process scheduling (CPU Scheduling)
MULTILEVEL QUEUE SCHEDULING
Memory Management in OS
Deadlock ppt
Mutual exclusion and sync
Semophores and it's types
Operating system components
Scheduling algorithms
Os unit 3 , process management
Memory management
Computer architecture virtual memory
Virtual memory
SCHEDULING ALGORITHMS
Operating Systems Process Scheduling Algorithms
Swapping | Computer Science
Memory management ppt
Basic MIPS implementation
Ad

Similar to OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES (20)

PPTX
session 4(system calls).pptxsession 4(system calls).pptx
PPT
ch2_OS Structures.ppt To discuss the various ways of structuring an operatin...
PDF
Ch2 operating-system structures
PPTX
Advanced Bulkification Strategies in Apex Triggers
PPTX
Lecture_02_Operating System Structures Operating Systems
PDF
02_os_structures.pdfbnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
PDF
Operating System Structure Part-I.pdf
PPTX
MODULE-1_Operating System Services - ppt
PPTX
Operating system 11 system calls
PPT
PDF
CH02.pdf
PPTX
2_System Calls.pptx
PPT
Operating System 2
PPT
OS - Ch2
PPT
Chapter 2 - Operating System Structures
PPTX
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
PPTX
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
PPT
OS Services, System call, Virtual Machine
PPT
operating system introduction and organization
PPT
System calls in Linux environment for beginners
session 4(system calls).pptxsession 4(system calls).pptx
ch2_OS Structures.ppt To discuss the various ways of structuring an operatin...
Ch2 operating-system structures
Advanced Bulkification Strategies in Apex Triggers
Lecture_02_Operating System Structures Operating Systems
02_os_structures.pdfbnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Operating System Structure Part-I.pdf
MODULE-1_Operating System Services - ppt
Operating system 11 system calls
CH02.pdf
2_System Calls.pptx
Operating System 2
OS - Ch2
Chapter 2 - Operating System Structures
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
OS Services, System call, Virtual Machine
operating system introduction and organization
System calls in Linux environment for beginners
Ad

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
Project quality management in manufacturing
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Digital Logic Computer Design lecture notes
PPTX
Internet of Things (IOT) - A guide to understanding
PPT on Performance Review to get promotions
Structs to JSON How Go Powers REST APIs.pdf
OOP with Java - Java Introduction (Basics)
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Arduino robotics embedded978-1-4302-3184-4.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Geodesy 1.pptx...............................................
Lesson 3_Tessellation.pptx finite Mathematics
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CH1 Production IntroductoryConcepts.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Operating System & Kernel Study Guide-1 - converted.pdf
Project quality management in manufacturing
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
bas. eng. economics group 4 presentation 1.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Digital Logic Computer Design lecture notes
Internet of Things (IOT) - A guide to understanding

OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES

  • 1. OPERATING SYSTEM Prepared by Ms. S. SHANMUGA PRIYA Senior Assistant Professor Department of CSE New Horizon College of Engineering Bangalore Karnataka.
  • 3. SAMPLE QUESTION List out the different services that an OS provides. Explain any two. (6 Marks)
  • 4. OPERATING SYSTEM SERVICES OS SERVICES SYSTEM PROGRAMS For ensuring efficiency of OS User Interface Program Execution I/O Operations File-System Manipulation Communication Error Detection Resource Allocation Accounting Protection and Security USERS
  • 5. A View of Operating System Services
  • 7. SAMPLE QUESTIONS • What are system calls? Explain the different categories of the system calls. (10 Marks) • What are system calls? With examples explain different categories of system calls. (7 Marks) • With examples, explain how system calls handle user applications. (6 Marks) • Explain any two types of system calls. (5 Marks) • Describe the various types of system calls. (7 Marks - Make up exam Jan 2018)
  • 8. • System Calls aka Kernel Call – System calls provide a means for user or application programs to call upon the services of the operating system. – Generally written in C or C++, although some are written in assembly for optimal performance.
  • 9. EXAMPLE OF SYSTEM CALL TASK: Write a simple C program to copy the content of one file to another file.
  • 11. STEPS INVOLVED • Acquire input file name • Write prompt to screen • Accept input • Acquire output file name • Write prompt to screen • Accept input • Open the input file • If file doesn't exist, abort • Create output file • If file exists • Loop • Read from input file • Write to output file • Until read fails • Close output file • Write completion message to screen • Terminate normally
  • 12. STEPS INVOLVED • Acquire input file name • Write prompt to screen • Accept input • Acquire output file name • Write prompt to screen • Accept input • Open the input file • If file doesn't exist, abort • Create output file • If file exists, • Loop • Read from input file • Write to output file • Until read fails • Close output file • Write completion message to screen • Terminate normally printf("n enter source file name"); gets(fname1); printf("n enter destin file name"); gets(fname2); fp1=fopen(fname1,"r"); fp2=fopen(fname2,"w"); if(fp1==NULL||fp2==NULL) { printf("unable to open"); exit(0); } do { ch=fgetc(fp1); fputc(ch,fp2); } while(ch!=EOF); fcloseall(); getch(); }
  • 13. SYSTEM CALL INVOLVED??? #include<stdio.h> #include<conio.h> void main() { FILE *fp1,*fp2; char ch, fname1[20], fname2[20]; printf("n enter source file name"); gets(fname1); printf("n enter source file name"); gets(fname2); fp1=fopen(fname1,"r"); fp2=fopen(fname2,"w"); if(fp1==NULL||fp2==NULL) { printf("unable to open"); exit(0); } do { ch=fgetc(fp1); fputc(ch,fp2); } while(ch!=EOF); fcloseall(); getch(); }
  • 15. • Frequently, systems execute thousands of system calls per second. • Most programmers never see this level of detail, however. • Typically, application developers design programs according to an Application Programming Interface (API).
  • 16. • A system call is a way for programs to interact with the operating system. • A computer program makes a system call when it makes a request to the operating system’s kernel. • System call provides the services of the operating system to the user programs via Application Program Interface(API). • It provides an interface between a process and operating system
  • 17. Application Programming Interface (API) • API specifies a set of functions that are available to an application programmer, including the parameters that are passed to each function and the return values the programmer can expect. (OR) • System of tools and resources in an OS enabling developers to create software applications. • As the operating system encounters these API functions, it takes the desired action, so the programmer does not need to know the details of controlling the hardware.
  • 18. SYSTEM CALLS Cont… • Typically, application developers design programs according to an Application Programming Interface (API). • Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use. • A programmer accesses an API via a library of code provided by the operating system. • In the case of UNIX and Linux for programs written in the C language, the library is called libc. • System call provides the services of the operating system to the user programs via Application Program Interface(API)
  • 19. • Each operating system has its own name for each system call. • Three most common APIs are: - Win32 API for Windows - POSIX API (Portable Operating System Interface) for POSIX-based systems (all versions of UNIX, Linux, and Mac OS X) - Java API for the Java Virtual Machine (JVM)
  • 22. SYSTEM CALLS Cont… • Behind the scenes, the functions that make up an API typically invoke the actual system calls on behalf of the application programmer. • For example, the Windows function CreateProcess( ) (which unsurprisingly is used to create a new process) actually invokes the NTCreateProcess( ) system call in the Windows kernel.
  • 23. SYSTEM CALLS Cont… • Why would an application programmer prefer programming according to an API rather than invoking actual system calls? • Program Portability –Programmer designing a program using an API can expect her program to compile and run on any system that supports the same API
  • 24. Example of Standard API • Consider the ReadFile() function • Win32 API—a function for reading from a file • A description of the parameters passed to ReadFile() – HANDLE file—the file to be read – LPVOID buffer—a buffer where the data will be read into and written from – DWORD bytesToRead—the number of bytes to be read into the buffer – LPDWORD bytesRead—the number of bytes read during the last read – LPOVERLAPPED ovl—indicates if overlapped I/O is being used
  • 25. SYSTEM CALL IMPEMENTATION • For most programming languages, the run-time support system (a set of functions built into libraries included with a compiler) provides a system call interface that serves as the link to system calls made available by the operating system. • The system-call interface intercepts function calls in the API and invokes the necessary system calls within the operating system. • Typically, a number is associated with each system call, and the system-call interface maintains a table indexed according to these numbers.
  • 26. SYSTEM CALL IMPEMENTATION Cont… • 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 • Managed by run-time support library (set of functions built into libraries included with compiler)
  • 27. API – System Call – OS Relationship (During Run-Time) SYSTEM CALL TABLE maintained by system call interface Invokes the necessary System call in the OS
  • 28. Standard C Library Example • C program invoking printf( ) library call, which calls write( ) system call
  • 29. 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 METHOD 1 Pass the parameters in registers Advantage - Simplest Method Disadvantage - In some cases, may be more parameters than registers
  • 30. METHOD 2 Block or table in memory Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register •Advantage –Do not limit the number or length of parameters being passed •Disadvantage –Uses user memory space This approach taken by Linux and Solaris PARAMETER PASSING VIA TABLE
  • 31. METHOD 3 – Use stack – Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system – Advantage • Do not limit the number or length of parameters being passed
  • 32. TYPES OF SYSTEM CALLS System calls can be grouped into 6 major categories: • Process Control • File Management • Device Management • Information Maintenance • Communications • Protection
  • 33. ◦ 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 PROCESS CONTROL includes the job’s priority, its maximum allowable execution time, so on… Module 3
  • 34. ◦ create file, delete file ◦ open, close ◦ read, write, reposition ◦ get file attributes, set file attributes FILE MANAGEMENT File Attributes Name, File Type, Protection Codes, Accounting Information, and so on Rewind or Skip to the end of the file
  • 35. ◦ request device, release device ◦ read, write, reposition ◦ get device attributes, set device attributes ◦ logically attach or detach devices DEVICE MANAGEMENT Main Memory Disk Drives, Access to Files, so on…
  • 36. INFORMATION MAINTENANCE ◦ get time or date, set time or date ◦ get system data, set system data ◦ get process, file, or device attributes ◦ set process, file, or device attributes
  • 37. COMMUNICATIONS ◦ create, delete communication connection ◦ send, receive messages ◦ transfer status information ◦ attach or detach remote devices
  • 38. • Protection was a concern only on multiprogrammed computer systems with several users. • System Calls providing protection include: – set permission( ) – get permission( ) – allow user( ) – deny user( ) PROTECTION Manipulate permission setting of resources such as files and disks Specify whether particular users can or cannot be allowed to access certain resources
  • 39. Examples of Windows and Unix System Calls
  • 41. SAMPLE QUESTION • Discuss briefly the various aspects to be considered while operating system is designed and implemented.
  • 42. OPERATING SYSTEM DESIGN AND IMPLEMENTATION • Design and Implementation of OS not “solvable”, but some approaches have proven successful i) DESIGN GOALS • PROBLEMS: • Defining goals and specifications • Varying internal structure of different Operating Systems • Affected by choice of hardware, type of system • Harder to specify requirements Batch, Time Sharing, Single User, Multi-User, Distributed, Real Time, or General Purpose
  • 43. OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont… REQUIREMENTS USER GOALS SYSTEM GOALS OS should be convenient to - use, - easy to learn, - reliable, - safe, and - fast OS should be - easy to design, - implement, - maintain, - flexible, - reliable, - error-free, and - efficient There is no unique solution to the problem of defining OS requirements
  • 44. ii) Mechanisms and Policies • Important principle to separate Policy : What will be done? Mechanism : How to do it? • For example, – Timer – Policy : How long the timer to be set for a particular user is a policy decision? - Mechanism : Ensuring CPU protection likely to change across places or over time Require a change in the underlying mechanism OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont…
  • 45. Implementation • Traditionally OSes were written in assembly language. This provided direct control over hardware-related issues, but inextricably tied a particular OS to a particular HW platform. • Recent advances in compiler efficiencies mean that most modern OSes are written in C, or more recently, C++. • Operating systems may be developed using emulators of the target hardware, particularly if the real hardware is unavailable (e.g. not built yet), or not a suitable platform for development, (e.g. smart phones, game consoles, or other similar devices.) OPERATING SYSTEM DESIGN AND IMPLEMENTATION Cont…
  • 47. SAMPLE QUESTIONS List out the various operating system structures. Explain them with suitable diagrams. Explain the advantage of layered approach with a neat diagram. (6 Marks) Explain the layered approach to the structuring of an operating system along with the relevant diagram. (10 Marks)
  • 48. • System as large and complex must be carefully engineered • Common Approach – Partition the task into small components rather than having one monolithic system • Design each modules with careful – Inputs – Outputs – Functions OPERATING SYSTEM STRUCTURE
  • 49. OPERATING SYSTEM STRUCTURE Cont… • Ways to interconnect components i) Simple Structure ii) Layered Approach iii) Microkernels iv) Modules v) Hybrid Systems  Mac OS X  iOS Android
  • 50. OPERATING SYSTEM STRUCTURE Cont… i) Simple Structure (Monolithic) - A monolithic kernel is an operating system architecture where the entire operating system is working in kernel space -Commercial system do not have well-defined structures - Such systems are started as small, simple, and limited and then grew beyond their original scope
  • 51. Example: MS-DOS –Written by a few programmers in a relatively short amount of time, without the benefit of modern software engineering techniques –It does not break the system into subsystems, and has no distinction between user and kernel modes, allowing all programs direct access to the underlying hardware.
  • 52. OPERATING SYSTEM STRUCTURE Cont… MS-DOS Structure Interfaces and functionalities are not well separated - Ex: Application program are able to directly access I/O routines to write directly to the display and disk drives - Problem : May leave MS- DOS vulnerable to malicious programs, cause system to crash - Limited by hardware functionality User directly access the hardwares A program (Terminate and Stay Resident) that remains in memory at all times for immediate availability. Ex: Quick pop up of calculator, calendar A device driver is a program that controls a particular type of device that is attached to your computer.
  • 53. OPERATING SYSTEM STRUCTURE Cont… Traditional UNIX System Structure Below the system-call interface and Above the physical hardware NOTE: Still see evidence of this simple, monolithic structure in the UNIX, Linux, and Windows operating systems
  • 54. OPERATING SYSTEM STRUCTURE Cont… UNIX • UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. • The UNIX OS consists of two separable parts – System Programs – The Kernel • Provides the • File System, • CPU Scheduling, • Memory Management, and • Other Operating-System Functions • Advantage : Less communication overhead • Disadvantage: Kernel becomes large and hard to manage No separable parts in MS-DOS A large number of functions for one level
  • 55. • Pros – Speed – Simplicity of design • Cons – Potential stability issues – Can become huge - Linux 2.6 has 7.0 million lines of code and Windows over 30 million! – Potentially difficult to maintain • Examples – Traditional Unix kernels – Linux – MS-DOS, Windows 9x – Mac OS versions below 8.6
  • 56. ii) LAYERED APPROACH • OS broken into pieces of smaller and appropriate one for supporting hardware's • Advantage: – OS will have much greater control over the computer and other applications – Implementers have freedom to change inner workings of systems – Information hiding is important, and can be implemented OPERATING SYSTEM STRUCTURE Cont…
  • 57. • How to make a system modular? • One Method is follow Layered Approach • What is a layered approach? – The operating system is broken into a number of layers (levels). – Each built on top of lower layers – Bottom Layer (layer 0)  Hardware – Highest Layer (layer N)  User Interface OPERATING SYSTEM STRUCTURE Cont…
  • 58. Layered Operating System Layer 5 : User Program Layer 4 : Buffering for Input and Output Devices Layer 3 : Operator-Console Device Driver Layer 2 : Memory Management Layer 1 : CPU Scheduling Layer 0 : Hardware Ex : Microsoft Windows NT OS
  • 59. Each module provide a set of functions that other module can call Interface functions at any particular level can invoke services provided by lower layers but not the other way around
  • 60. • Advantages – Simplicity of construction and debugging – Layers are selected such that each uses functions (operations) and services of only lower-level layers – Layers know only what they must do, hence hides the existence of data structures, operations and hardware from higher-level OPERATING SYSTEM STRUCTURE Cont… Layered Approach
  • 61. • Disadvantages – Difficult in defining various layer with appropriate functionalities – Ex: Device driver for the backing store must be at lower level than the memory management routines, because, memory managements requires the ability to use the backing stores – Less efficient, due to multiple level leads to communication overhead. OPERATING SYSTEM STRUCTURE Cont… Layered Approach
  • 62. OPERATING-SYSTEM STRUCTURE Cont… iii) MICROKERNELS • Kernel – If it expands, difficult to manage • Designed in 1980s, researchers at Carnegie Mellon University developed an operating system called Mach that modularized the kernel using the microkernel approach. • Designing Approach: – Removed all nonessential components from kernel and implemented them as system and user-level program – Result : Small kernel – Example: QNX, a real-time OS for Embedded Systems
  • 65. • Functions Provided by Kernel: – Provides communication facility between the client program and various services running in user space – takes place between user modules using message passing OPERATING-SYSTEM STRUCTURE Cont… MICROKERNEL Communication
  • 66. OPERATING-SYSTEM STRUCTURES Cont… MICROKERNEL iii) Microkernel • Benefits: – Easier to extend a microkernel – Easier to port the operating system to new architectures – More reliable (less code is running in kernel mode) – Stability • Detriments: – Additional context switches are usually required – Performance overhead of user space to kernel space communication – Slow Inter Process Communication can result in poor performance
  • 68. OPERATING-SYSTEM STRUCTURES Cont… MODULES iv) 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 kernel modules as needed within the kernel • Overall, similar to layers but with more flexible During boot time or run time
  • 69. Solaris Modular Approach Solaris OS Core Kernel with 7 types of loadable kernel modules
  • 70. • Modules are similar to layers in that each subsystem has clearly defined tasks and interfaces, but any module is free to contact any other module, eliminating the problems of going through multiple intermediary layers, • The kernel is relatively small in this architecture, similar to microkernels, but the kernel does not have to implement message passing since modules are free to contact each other directly.
  • 71. • In practice, very few operating systems adopt a single, strictly defined structure. • Instead, they combine different structures, resulting in hybrid systems that address performance, security, and usability issues. • For example, – Linux and Solaris are monolithic, and also modular – Windows is • largely monolithic as well, but it retains some behavior typical of microkernel system • support for dynamically loadable kernel modules (Windows 7) HYBRID SYSTEM OS have single address space Functionalities can be added dynamically
  • 72. HYBRID SYSTEM – MAC OS X • Mac OS X is a layered system Top layer includes user interface, application environments and services Specifies an API for the Objective - C programming language, which is used for writing Mac OS X applications Apple's native object- oriented application programming interface (API) for their operating system MacOS An extensible multimedia framework developed by Apple Inc., capable of handling various formats of digital video, picture, sound, panoramic images, and interactivity.
  • 74. Dashboard View in Mac OS X
  • 75. • iOS is a – mobile operating system designed by Apple to run its smartphone iPhone, as well as its tablet computer, the iPad. • iOS is structured on the Mac OS X operating system, with added functionality pertinent to mobile devices, but does not directly run Mac OS X applications. HYBRID SYSTEM – iOS
  • 77. Cocoa Touch is an API for Objective-C that provides several frameworks for developing applications that run on iOS devices NOTE: Cocoa Touch provides support for hardware features unique to mobile devices, such as touch screens. The media services layer provides services for graphics, audio, and video The core services layer provides a variety of features, including support for cloud computing and databases. The bottom layer represents the core operating system, which is based on the kernel environmentLAYERED STRUCTURE