0% found this document useful (0 votes)
47 views

Chapter 1: Introduction: (OS Structure, Modes and Services)

The document discusses the structure and functions of operating systems. It describes operating systems as programs that act as an interface between users and computer hardware, managing resources and controlling execution of other programs. The main components of a computer system are hardware, operating system, application programs, and users. Operating systems provide services like executing user programs, managing system resources efficiently, and preventing errors. Common operating system structures include simple, layered, monolithic, microkernel, and hybrid kernel designs. [END SUMMARY]

Uploaded by

Nikhil Tata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Chapter 1: Introduction: (OS Structure, Modes and Services)

The document discusses the structure and functions of operating systems. It describes operating systems as programs that act as an interface between users and computer hardware, managing resources and controlling execution of other programs. The main components of a computer system are hardware, operating system, application programs, and users. Operating systems provide services like executing user programs, managing system resources efficiently, and preventing errors. Common operating system structures include simple, layered, monolithic, microkernel, and hybrid kernel designs. [END SUMMARY]

Uploaded by

Nikhil Tata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 58

Chapter 1: Introduction

(OS Structure, Modes and Services)


What is an Operating System?
 A program that acts as an intermediate/ interface between a
user of a computer and the computer hardware.
 Resource allocator
 Control Program

 Operating system goals:


 Execute user programs and make solving user problems easier
 Make the computer system convenient to use
 Use the computer hardware in an efficient manner
Computer System Structure

 Computer system can be divided into four components


 1. Hardware – provides basic computing resources
 CPU, memory, I/O devices
 2. Operating system
 Controls and coordinates use of hardware among
various applications and users
 3. Application programs – define the ways in which the
system resources are used to solve the computing
problems of the users
 Word processors, compilers, web browsers, database
systems, video games
 4. Users
 People, machines, other computers
Four Components of a Computer System
Operating System Definition
To understand more fully the OS role, we explore OS from 2 view
points.:
1. User view: In single user, it should be easy to use.
In other cases, where users access the same user through
different terminals, More emphasize is on resource allocation
and utilization.

2. System View:
 OS is a resource allocator
 Manages all resources
 Decides between conflicting requests for efficient and fair
resource use
 OS is a control program
 Controls execution of programs to prevent errors and
improper use of the computer
Who controls the execution of programs to
prevent errors and improper use of
computer?
a) Resource allocator
b) Control Program
c) Hardware
d) None of the above
Operating-System Operations
 Modern OS’s are Interrupt driven.
 Program or software send generate events by using system calls.
Error or request by a software creates exception or trap
 Division by zero, request for operating system service

 Dual-mode operation allows OS to protect itself and other system


components
 User mode and kernel mode

 Mode bit provided by hardware


 Provides ability to distinguish when system is running user
code or kernel code
Transition from User to Kernel Mode
The operating system switches from user
mode to kernel mode so the mode bit will
change from?
a) 0 to 1
b) 1 to 0
c) Remain constant
d) None
Computer System Organization
 Computer-system operation
 One or more CPUs, device controllers connect through common bus
providing access to shared memory
 Concurrent execution of CPUs and devices competing for memory
cycles
TYPES OF OS

Batch Systems
 Early computers were Physically enormous machines run from a
console
 The common input devices were card readers and tape drives.
 The common output devices were line printers, tape drives, and
card punches.
 The user did not interact directly with the computer systems.
 User prepare a job -which consisted of the program, and submitted it
to the computer operator.
 after minutes, hours, or days, the output appeared.
 To speed up processing, operators batched jobs with similar needs
together and ran them through the computer as a group.
In which type of operating system users do
not interact directly with the computer
system?
a) Multiprogramming operating systems
b) Multiprocessing operating systems
c) Batch operating systems
d) Distributed operating systems
Multiprogrammed OS
 Needed for efficiency
 Single user cannot keep CPU and I/O devices busy at
all times
 Multiprogramming organizes jobs (code and data) so
CPU always has one to execute
 A subset of total jobs in system is kept in memory
 One job selected and run via job scheduling
 When it has to wait (for I/O for example), OS switches
to another job
What is the objective of multiprogramming
operating systems?
a) Maximize CPU utilization
b) Switch the CPU among processes
c) Achieve multitasking
d) None of the above
Timesharing OS
 Timesharing (multitasking) is logical extension in
which CPU switches jobs so frequently that users can
interact with each job while it is running, creating
interactive computing
 Each user has at least one program executing in
memory process
 If several jobs ready to run at the same time  CPU
scheduling
 If processes don’t fit in memory, swapping moves
them in and out to run
 Virtual memory allows execution of processes not
completely in memory
Multitasking Systems
 Types of Multitasking:

1. Preemptive: the operating system parcels CPU time


slices to each program.

2. Cooperative: each program can control the CPU for as


long as it needs it.
If a program is not using the CPU, however, it can
allow another program to use it temporarily.
Multiprocessing OS
 Multi-processor systems; that is, they have multiple
CPU.

 Exp: dual core processor has 2 process cycles

 Also known as parallel systems or tightly coupled


systems

 Such systems have more than one processor in close


communication, sharing the computer bus, the clock,
and sometimes memory and peripheral devices.
Distributed Systems

 A network is a communication path between two or more


systems.
 Each system over the network keeps copy of the data,
and this leads to Reliability (Because if one system
crashes , data is not lost).

 CLIENT SERVER SYSTEMS


 PEER TO PEER SYSTEMS
Real Time Systems
 Time bound systems
 Real time systems are of 2 types:

 1. Soft Real time Systems: Process should complete in specific


time but May have some delay (Positive delay) and will nor harm the
system.
 Exp: Session expires but can be re-logged in.

 2. Hard Real Time Systems: Each process is assigned a specific


time instance, and Process must complete in that time otherwise
system will crash.
Real Time Embedded Systems
 is a computing environment that reacts to input within
a specific time period.

 Time Driven

 Task specific

 Exp: Microwave, Washing Machine…


Operating System Structure

 General-purpose OS is very large program


 Various ways to structure ones
 Simple structure – MS-DOS
 More complex -- UNIX
 Layered – an abstraction
 Microkernel -Mach
Simple Structure -- MS-DOS

 MS-DOS – written to
provide the most
functionality in the least
space
 Not divided into modules
Non Simple Structure -- UNIX
UNIX – limited by hardware functionality
The UNIX OS consists of two separable parts:

 Systems programs

 The kernel
Traditional UNIX System Structure
Beyond simple but not fully layered
Layered Approach
 The operating system is divided
into a number of layers (levels)
 Each layer is built on top of
lower layers.
 The bottom layer (layer 0), is the
hardware; the highest (layer N)
is the user interface.
 With modularity, layers are
selected, each layer uses
functions (operations) and
services of only lower-level
layers
Architecture of a Linux system −
 Hardware layer − Hardware consists of all
peripheral devices (RAM/ HDD/ CPU etc).
 Kernel − It is the core component of
Operating System, interacts directly with
hardware, provides low level services to
upper layer components.
 Shell − An interface to kernel, hiding
complexity of kernel's functions from
users. The shell takes commands from the
user and executes kernel's functions.
Kernel
 Kernel is the core part of Linux. It is
responsible for all major activities of this
operating system.
 It consists of various modules and it
interacts directly with the underlying
hardware.
Monolithic Kernels

 All OS services operate in kernel space


 Good performance
 Disadvantages
 Dependencies between system component
 Complex & huge (millions(!) of lines of code)
 Larger size makes it hard to maintain
 E.g. Unix, BSD, Linux
Monolithic Structure

Main function

OS services

Utility
functions
Microkernel System Structure
 Communication takes place between user modules
using message passing
 Example of microkernel: Mach
 Mac OS X kernel (Darwin) partly based on Mach

 Benefits:
 Easier to extend a microkernel
 Easier to port the operating system to new architectures
 More reliable (less code is running in kernel mode)
 More secure
 Disadvantage:
 Performance overhead of user space to kernel space
communication
Microkernel System Structure

Application File Device user


Program System Driver mode

messages messages

Interprocess memory CPU kernel


Communication managment scheduling mode

microkernel

hardware
Monolithic Kernels VS Micro kernels
Hybrid Kernels
 Combine the best of both worlds
 Speed and simple design of a monolithic
kernel
 Modularity and stability of a microkernel
 Still similar to a monolithic kernel
 Disadvantages still apply here
 E.g. Windows NT
Operating System Services
 An operating system provides an environment for the programs to run.
 It provides certain services to programs
Operating System Services
 Operating-system services provides functions that are helpful to the
user:

 User interface - Almost all operating systems have a user


interface (UI)
 Varies between Command-Line (CLI), Graphics User
Interface (GUI).

 Program execution - The system must be able to load a


program into memory and to run that program, end
execution, either normally or abnormally (indicating error)
Operating System Services

 I/O operations - A running program may require I/O, which may


involve a file or an I/O device.

 File-system manipulation - read and write files and directories,


create and delete them, search them, list file Information,
permission management.
Operating System Services

 Error detection – OS needs to be constantly aware of


possible errors
 May occur in the CPU and memory hardware, in I/O devices,
in user program
 For each type of error, OS should take the appropriate
action to ensure correct and consistent computing
 Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system.
Operating System Services

 Communications – Processes may exchange information, on


the same computer or between computers over a network
 Communications may be via shared memory or through
message passing (packets moved by the OS)

 Resource allocation – OS must ensure allocation of resources


to all programs running.

 Manytypes of resources - such as CPU cycle time, main


memory, and file storage, I/O devices
Operating System Services
 Accounting - To keep track of which users use how much and
what kinds of
computer resources.

 Protection and Security -

 Protection involves ensuring that all access to system


resources is controlled
 Security of the system from outsiders requires user
authentication, extends to defending external I/O devices
from invalid access attempts
Interrupts
 The occurrence of any event is signaled by interrupt.
 Hardware trigger an interrupt at any time by sending signal to CPU
through system bus.
 Software may trigger an interrupt by executing a special operation
called system call.
 Modern OS s are Interrupt driven. If there is no process, no I/o
devices, No users then Os will sit quietly waiting for some event to
occur.
 Program or software send, generate events by using system calls.
Error or request by a software creates exception or trap
 Request for operating system service
 Since OS and users share h/w, s/w resources, we make to sure that
an error in a program does not affect any other program.
I/O interrupt

 To start an i/o operation CPU loads the


appropriate register within the device controller.
 Device controller examines the content of
register and take the decision.
 Two types are there:
 Synchronous i/o
 Asynchronous i/o
Synchronous and Asynchronous
I/O Interrupts
Device status table
 Who signalled for the occurrence of an
event either from the hardware or the
software?
a) Bootstrap program
b) Interrupt
c) Disk Controller
d) CPU
(b)
 In which type of I/O interrupts the control
return to the user program after the
completion of I/O operation?
a) Synchronous I/O interrupts
b) Asynchronous I/O interrupts
c) System Call
d) Hardware
(a)
 The device-status table contains
a) each I/O device type
b) each I/O device state
c) each I/O device address
d) all of the above
(d)
System Calls
 Provide an interface to the services made available by
an OS
 Typically written in a high-level language (C or C++)
Example of System Calls
 System call sequence to copy the contents of one file to
another file
System Call Implementation
 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
 Most details of OS interface hidden from programmer
System Call – OS Relationship
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
 Simplest: pass the parameters in registers
 In some cases, may be more parameters than registers
 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
 Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system
 Block and stack methods do not limit the number or length of
parameters being passed
Types of System Calls

 Process control
End, abort, load, execute, create process, terminate process, wait, get
process attributes, set attributes.
 File management
Create file, delete file, open, close, read, write, reposition.
 Device management
Request device, release device, read, write, logically attach and
detach device.
 Information maintenance
Get time, date, set time date, get system data, set system data.
 Communications
Create, delete communication connection, send receive messages,
transfer status information.
Process Control Calls
 fork() – create a new process
pid = fork();
 The fork() function shall create a new process. The new process
(child process) shall be an exact copy of the calling process
(parent process) except some process’ system properties
 It returns ‘twice’
return value == 0 ... child
return value > 0 ... parent (returned value is the child’s pid)
 exit() – terminate a process
void exit(int status);
 The exit() function shall then flush all open files with unwritten
buffered data and close all open files. Finally, the process shall be
terminated and system resources owned by the process shall be
freed
 The value of ‘status’ shall be available to a waiting parent process
 The exit() function should never return
File Access Calls
 open – open file
fd = open(const char *path, int oflag, ...);
 The open() function shall establish the connection between a file
and a file descriptor. The file descriptor is used by other I/O
functions to refer to that file. The path argument points to a
pathname naming the file.
 The parameter oflag specifies the open mode:
ReadOnly, WriteOnly, ReadWrite
Create, Append, Exclusive, ...

 close – close a file descriptor


err = close(int fd);
 The close() function shall deallocate the file descriptor indicated by
fd. To deallocate means to make the file descriptor available for
return by subsequent calls to open() or other functions that allocate
file descriptors.
 When all file descriptors associated with an open file description
have been closed, the open file description shall be freed.
 Who provides the interface between a
process and the operating system?
a) Interrupt
b) System calls
c) CPU
d) Device Controller
(b)
 System call routines of operating system
are mostly written in
a) C
b) C++
c) java
d) both a and b
(d)
Any Query
???

You might also like