You are on page 1of 74

Operating System

CAF 614
Syllabus

Unit 1: Introduction to Operating System. (8 L)


• Introduction:
• Components of a computer System,
• Operating system: User view & System view,
• Evolution of operating system,
• Single Processor & Multiprocessor systems,
• Real Time System,
• Distributed Systems,
• Multimedia Systems,
• Handheld Systems.
• Operating System Structure:
• Operating System Services,
• User Operating System Interfaces: Command- Line and GUI,
• System Calls.
2
CSF614 – Operating System
Unit – 1 Lecture – 2
Learning Objectives
In this Lecture you will learn about:

• Introduction to OS
• Component of Computer System
• Operating System view: User’s view & System view
• Evolution of OS

4
Introduction to Operating Systems

• An Operating system is the resource manager i.e. it can manage the resource of a
computer system internally.
• The resources are processor, memory, files, and I/O devices. In simple terms, an
operating system is the interface between the user and the machine.

5
Structure of Operating System
(Contd…):

• The structure of OS consists of 4 layers:


1.Hardware
Hardware consists of CPU, Main
memory, I/O Devices, etc,

2.Software (Operating System)


Software includes process
management routines, memory
management routines, I/O
control routines, file
management routines. 6
3.System programs
This layer consists of compilers,
Assemblers, linker etc.

4.Application programs
This is dependent on users need. Ex.
MS-Office, Browsers, Railway
reservation system, Bank database
management etc.,

7
Introduction to Operating Systems

• Operating System Management Tasks

• Processor management which involves putting the tasks into order and
pairing them into manageable size before they go to the CPU.
• Memory management which coordinates data to and from RAM (random-
access memory) and determines the necessity for virtual memory.
• Device management which provides interface between connected devices.

• Storage management which directs permanent data storage.

• Application which allows standard communication between software and


your computer.
• User interface which allows you to communicate with your computer.

8
Introduction to Operating Systems

EXAPMLE OF OPERATING SYSTEM


1. Microsoft Disk operating system (MS-DOS)
2. Windows ( 98, 2000, XP, vista, Window 7/8/10)
3. Linux
4. Unix

9
Introduction to Operating Systems

Classification of Operating System

Based on number of task handled Based on number of users Based on user interface
concurrently

Single User: Operates a Command Line: Use the


Single Task: One task is user at a given time
operated at a any given time commands to activate any
Multi User: More than programmes e.g. MS-DOS
Multi-Task: More than one one user can operate a
task is executed Graphical User Interface:
given computer at any The user interacts with the
simultaneously time computer using icons and
menus and select them
using pointer

10
Introduction to Operating Systems

Objective of Operating System


• Convenience: Convenient to use.
• Efficiency: Use resources efficiently.

11
Two Views of Operating System

Two Views of Operating System

Operating System View:


User’s View: As a resource allocator also.
It refers to the interface being used. A computer system consists of many resources
The operating system is designed mostly for like - hardware and software - that must be
ease of use, with some attention paid to managed efficiently.
performance, and none paid to resource Acts as the manager of the resources, decides
utilization. between conflicting requests, controls
execution of programs etc.

12
Modes of Operation

User Mode Kernel Mode


• user program executes in user • monitor executes in kernel mode
mode • privileged instructions may be
• certain areas of memory are executed
protected from user access • protected areas of memory may
• certain instructions may not be be accessed
executed

13
Operating-System Operations

• 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

• Some instructions designated as privileged, only executable in kernel mode

• System call changes mode to kernel, return from call resets it to user

• Increasingly CPUs support multi-mode operations


• i.e. virtual machine manager (VMM) mode for guest VMs
Transition from User to Kernel Mode
CSF614 – Operating System
Unit – 1 Lecture – 3
Learning Objectives
In this Lecture you will learn about:

• Single Processor and Multiprocessor System


• Symmetric and Asymmetric System
• Real Time System
• Distributed System

17
Uniprogramming

• The processor spends a certain amount of time executing, until it reaches an


I/O instruction; it must then wait until that I/O instruction concludes before
proceeding.

18
Evolution of Operating Systems

 A major OS will evolve over time for a number of


reasons:

Hardware upgrades

New types of hardware

New services

Fixes

19
Evolution of Operating Systems

 Stages include:

Time
Multiprogram Sharing
med Batch Systems
Simple Systems
Batch
Serial Systems
Processi
ng

20
Serial Processing

Earliest Computers: Problems:

• No operating system • Scheduling:


• programmers interacted • most installations used a hardcopy
directly with the computer sign-up sheet to reserve computer
hardware time
• Computers ran from a console with • time allocations could run
display lights, toggle switches, some short or long, resulting in
form of input device, and a printer wasted computer time
• Users have access to the computer in • Setup time
“series” • a considerable amount of time was
spent just on setting up the program
to run

21
Simple Batch Systems

• Early computers were very expensive


• important to maximize processor utilization
• Monitor/Computer operator [Execute in kernel mode]
• user no longer has direct access to processor
• job is submitted to computer operator who batches them together and places
them on an input device
• program branches back to the monitor when finished

22
Batch Processing:

• In Batch processing same type of jobs batch (BATCH- a set of jobs with similar needs)
together and execute at a time.
• The OS was simple, its major task was to transfer control from one job to the next.
• The job was submitted to the computer operator in form of punch cards. At some later time
the output appeared.
• The OS was always resident in memory. (Ref. Fig. next slide)
• Common Input devices were card readers and tape drives.

23
Batch Processing (Contd…):
• Common output devices were line printers, tape drives, and card punches.
• Users did not interact directly with the computer systems, but he
prepared a job (comprising of the program, the data, & some control
information).
OS

User
progra
m area

24
Simple Batch Systems

• Advantages of Batch Operating System:


• Multiple users can share the batch systems.

• The idle time for batch system is very less

• It is easy to manage large work repeatedly in batch systems


• Disadvantages of Batch Operating System:
• The computer operators should be well known with batch systems.

• hard to debug.

• The other jobs will have to wait for an unknown time if any job fails

25
Multiprogramming

• There must be enough memory to hold the OS (resident monitor) and one user program

• When one job needs to wait for I/O, the processor can switch to the other job, which is
likely not waiting for I/O

26
Multiprogramming
• Multiprogramming

• memory is expanded to hold three, four,


or more programs and switch among all
of them

27
What is Multiprogramming?

A multiprogramming operating system can run several programs on a single

processor machine. If a single application has to wait for I/O transfer in a

multiprogramming operating system, other programs are always ready to use the

CPU. As a result, numerous jobs can share the CPU's time. However, in a

multiprogramming operating system, it is not predefined that their jobs would be

executed simultaneously.

If a program is in the process of being executed, it is referred to as a "Process",

"Job", or "Task". Simultaneous program executions help increase system

resource utilization and system throughput performance compared to serial and

batch processing systems.


28
Advantages and disadvantages of multiprogramming

There are various advantages and disadvantages of multiprogramming. Some of them are as

follows:

Advantages:

1. It provides high CPU utilization.

2. It has a shorter response time.

3. Increases resource utilization

4. It can assign priority to the jobs.

5. Maximizes total job throughput of a computer

Disadvantages

6. Its scheduling implementation is not easy.


29
7. It required more management.
What is Multitasking?
Multitasking means working on multiple tasks simultaneously, such as using your
computer while listening to music. Also, using a browser, search for something on the
internet and create a word document that is your assignment. It appears that all of the tasks
are taking place at the same time. It is not all of the tasks happening simultaneously; the
processor moves between them at such a fast pace that we believe they are happening
simultaneously.

30
Multitasking contd.

• Multitasking is similar to multiprogramming in that the CPU is assigned to a process for


a specified period of time, i.e., 'Time quantum or time slice', after which the CPU
'Context switches' to another process. It runs various programs at the same time.

• The PC requires a huge memory to execute multitasking (RAM ). Its primary goal is to
improve the timing of the CPU's response. Users can engage with the system during
multitasking, for example, by typing a letter while the printing process is running.

• Multitasking is a highly complicated system. It is based on the time slice principle,


which assigns a fixed amount of time to each activity to be completed. It is especially
useful when a program requires a high level of parallelism. It provides a set amount of
time for each program to run.

31
Advantages and disadvantages of multitasking

There are various advantages and disadvantages of multitasking. Some of them are as

follows:

Advantages

1. It provides logical parallelism.

2. It provides a shorter response time.

3. It provides CPU utilization.

Disadvantages

4. It couldn't be executed on a slow-speed processor.

5. It needs a large amount of storage memory to do the work. 32


Time-Sharing Systems

• Can be used to handle multiple interactive jobs

• Processor time is shared among multiple users

• Multiple users simultaneously access the system through terminals, with the OS
interleaving the execution of each user program in a short burst or quantum of
computation

33
Batch Multiprogramming
vs. Time Sharing

The main difference between Multi programmed Batch Systems, and Time-Sharing
Systems is that in multiprogrammed batch systems, the objective is to maximize processor
use.
In contrast, in Time-Sharing Systems, the objective is to minimize response time

34
Multiprocessor System

• have two or more central processing units (CPUs) share full access to a
common RAM.

• Objective is to boost the system’s execution speed, with other objectives being
fault tolerance and application matching.

• Two types of multiprocessors are:

• shared memory multiprocessor - all the CPUs shares the common memory

• distributed memory multiprocessor - every CPU has its own private


memory

• Benefits:

• Enhanced performance.

• Multiple applications.

• Multi-tasking inside an application.

• High throughput and responsiveness.

• Hardware sharing among CPUs.


35
Symmetric and Asymmetric System

• Multiprocessing is the use of two or more central processing units within a single computer
system.
• Asymmetric Multiprocessing and Symmetric Multiprocessing

• Symmetric Multiprocessing:

• It involves a multiprocessor computer hardware and software architecture where two or


more identical processors are connected to a single, shared main memory, have full
access to all input and output devices,
• In other words, Symmetric Multiprocessing is a type of multiprocessing where each
processor is self-scheduling.
• For example, SMP applies multiple processors to that one problem, known as parallel
programming.

36
In these types of systems, each processor contains a similar copy of the
operating system and they all communicate with each other. All the
processors are in a peer to peer relationship i.e. no master - slave
relationship exists between them.

37
Symmetric and Asymmetric System

• Asymmetric Multiprocessing:

• It is multiprocessor computer system where not all of the multiple interconnected


central processing units (CPUs) are treated equally.
• In asymmetric multiprocessing, only a master processor runs the tasks of the
operating system.
• For example, AMP can be used in assigning specific tasks to CPU based on priority
and importance of task completion.

38
In asymmetric systems, each processor is given a predefined task. There is
a master processor that gives instruction to all the other processors.
Asymmetric multiprocessor system contains a master slave relationship.

39
Advantages of Multiprocessor Systems

• More reliable Systems


• Enhanced Throughput

Disadvantages of Multiprocessor Systems

• Increased Expense
• Complicated Operating System Required
• Large Main Memory Required

40
Distributed Operating Systems

• Various autonomous interconnected computers


communicate each other using a shared communication
network.

• Independent systems possess their own memory unit and


CPU.

• also known as loosely coupled systems

• These systems processors may differ in sizes and


functions.

• The major benefit


• it is always possible that one user can access the files or
software which are not actually present on his system but on
some other system connected within this network i.e., remote
access is enabled within the devices connected in that network.
41
Distributed Operating Systems

• Advantages of Distributed Operating System:


• Failure of one will not affect the other network communication, as all systems are independent
from each other
• Since resources are being shared, computation is highly fast and durable
• Load on host computer reduces
• These systems are easily scalable as many systems can be easily added to the network

• Disadvantages of Distributed Operating System:


• Failure of the main network will stop the entire communication
• To establish distributed systems the language which are used are not well defined yet
• These types of systems are not readily available as they are very expensive.

• Examples of Distributed Operating System are- LOCUS etc.

42
CAF614 – Operating System
Unit – 1 Lecture4
Learning Objectives
In this Lecture you will learn about:
• Multimedia System
• Real Time System
• Handheld System
• Mobile System
• Cloud System

44
Real Time System

• Used in environments where a large number of events, mostly external to the computer system, must
be accepted and processed within certain deadlines.

• Like in industrial control, telephone switching equipment, flight control, and real time simulations.

• The real time operating systems can be of 2 types –


• Hard Real Time operating system:

• guarantee that critical tasks be completed within a range of time.

• For example, a robot is hired to weld a car body, if robot welds too early or too late, the car
cannot be sold, so it is a hard real time system that require to complete car welding by robot
hardly on the time.
• Soft real time operating system:

• provides some relaxation in time limit.

• For example – Multimedia systems, digital audio system etc.

45
Real Time System

• Advantage:
• Maximum consumption –
• Maximum utilization of devices and system. Thus more output from all the resources.
• Task Shifting –
• Time assigned for shifting tasks in these systems are very less. For example in older systems it
takes about 10 micro seconds. In shifting one task to another and in latest systems it takes 3
micro seconds.
• Focus On Application –
• Focus on running applications and less importance to applications which are in queue.
• Real Time Operating System In Embedded System –
• Since size of programs are small, RTOS can also be embedded systems like in transport and
others.
• Error Free –
• These types of systems are error free.

46
Multimedia System

• In multimedia applications, a lot of data manipulation (e.g. A/D, D/A and format conversion) is required
and this involves a lot of data transfer, which consumes many resources.

• The integration of discrete and continuous multimedia data demands additional services from many
operating system components.

• The major aspect in this context is real-time processing of continuous media data.

• Issues concerned:

• Process management: a brief presentation of traditional real-time scheduling algorithms.

• File systems: outlines disk access algorithms, data placement and structuring

• Interprocess communication and synchronization.

47
COMPUTER-BASED MULTIMEDIA
Technological advances have changed the hardware and software used for
developing multimedia from the traditional analog equipment to computer-
based or digital multimedia systems. Computers use 0s and 1s to store and
process sounds, still graphics (pictures), and motion video. Text scanning,
digital imaging (using digital cameras and scanners), sound cards, and analog
video-capturing devices sample, compress, and convert analog media into a
series of 0s and 1s (digital) signals for processing by a computer. Once analog
media are converted to a digital format, a computer can be used to manipulate
the various media. With the development of digital-video cameras and digital-
still cameras, media are already in a form that the computer can process,
making it easier to merge text, graphics, video, sounds, and animation into an
application.
48
Handheld System

• It is a small portable devices that can be carried along and are capable of performing normal operations.

• They are usually battery powered.

• Examples include Personal Digital Assistants (PDAs), mobile phones, palm-top computers, pocket-PCs
etc.

• Weights and sizes have certain limitations as a result they are equipped with small memories, slow
processors and small display screens, etc.

• The physical memory capacity is very less (512 KB to 128 MB) hence the operating systems of these
devices must manage the memory efficiently.

• As the processors are slower due to battery problem, the operating system should not burden.

49
CAF614 – Operating System
Unit – 1 Lecture 5
Learning Objectives
In this Lecture you will learn about:

• Operating System services

• User System Interfaces: cmd & GUI

• Components

51
A View of Operating System Services

52
Operating System Services

• Operating systems provide an environment for execution of programs and services to programs
and users

• One set of 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), Batch

• 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)
• I/O operations - A running program may require I/O, which may involve a file or an I/O
device

53
Operating System Services (Cont.)

• One set of operating-system services provides functions that are helpful to the user (Cont.):

• File-system manipulation - The file system is of particular interest. Programs need to read and write files
and directories, create and delete them, search them, list file Information, permission management.
• 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)

• 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

54
Operating System Services (Cont.)

• Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing

• Resource allocation - When multiple users or multiple jobs running concurrently, resources must
be allocated to each of them
• Many types of resources - CPU cycles, main memory, file storage, I/O devices.

• Accounting - To keep track of which users use how much and what kinds of computer resources

• Protection and security - The owners of information stored in a multiuser or networked


computer system may want to control use of that information, concurrent processes should not
interfere with each other
• 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

55
User Operating System Interface - CLI

CLI or command interpreter allows direct command entry


• Sometimes implemented in kernel, sometimes by systems program

• Sometimes multiple flavors implemented – shells

• Primarily fetches a command from user and executes it

• Sometimes commands built-in, sometimes just names of programs


• If the latter, adding new features doesn’t require shell modification

56
Bourne Shell Command Interpreter

57
User Operating System Interface - GUI

• User-friendly desktop metaphor interface


• Usually mouse, keyboard, and monitor
• Icons represent files, programs, actions, etc
• Various mouse buttons over objects in the interface cause various actions (provide
information, options, execute function, open directory (known as a folder)
• Invented at Xerox PARC

• Many systems now include both CLI and GUI interfaces


• Microsoft Windows is GUI with CLI “command” shell
• Apple Mac OS X is “Aqua” GUI interface with UNIX kernel underneath and shells
available
• Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)
58
Touchscreen Interfaces

Touchscreen devices require new


interfaces
Mouse not possible or not desired
Actions and selection based on
gestures
Virtual keyboard for text entry
Voice commands.

59
CAF614 – Operating System
Unit – 1 Lecture 6
Learning Objectives
In this Lecture you will learn about:

• System Call and its type,


• OS Operation

61
System Calls

• It is the programmatic way in which a computer program requests a service from the kernel of the
operating system it is executed on.
• 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 to allow user-level processes to
request services of the operating system.
• System calls are the only entry points into the kernel system.
• All programs needing resources must use system calls.
• Services Provided by System Calls :
• Process creation and management
• Main memory management
• File Access, Directory and File system management
• Device handling(I/O)
• Protection
• Networking, etc.
62
Example of System Calls

• System call sequence to copy the contents of one file to another file
Types of System Calls

• File management
• create file, delete file

• open, close file

• read, write, reposition

• get and set file attributes

• Device management
• request device, release device

• read, write, reposition

• get device attributes, set device attributes

• logically attach or detach devices

64
• 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 if message passing model to host name or process name

• From client to server

• Shared-memory model create and gain access to memory regions

• transfer status information

• attach and detach remote devices


65
Types of System Calls (Cont.)

• Protection
• Control access to resources

• Get and set permissions

• Allow and deny user access

66
Examples of Windows and Unix System Calls

67
API – System Call – OS Relationship
Standard C Library Example
• C program invoking printf() library call, which calls write() system
call
fork() in C

Fork system call is used for creating a new process, which is called child process, which
runs concurrently with the process that makes the fork() call (parent process). After a
new child process is created, both processes will execute the next instruction following
the fork() system call. A child process uses the same pc(program counter), same CPU
registers, same open files which use in the parent process.

It takes no parameters and returns an integer value. Below are different values returned
by fork()

70
Fork() return values:
1. Negative Value: creation of a child process was unsuccessful.
2. Zero: Returned to the newly created child process.
3. Positive value: Returned to parent or caller. The value contains process ID of newly
created child process.

71
int main()
{

// make two process which run same


// program after this instruction
fork();

printf("Hello world!\n");
return 0;
}
Output:

Hello world!
Hello world!

72
Calculate number of times hello is printed

int main()
{
fork();
fork();
fork();
printf("hello\n");
return 0;
}
Output:

hello
hello
hello
hello
hello
hello
hello
hello
The number of times ‘hello’ is printed is equal to number of process created. Total Number
of Processes = 2n, where n is number of fork system calls. So here n = 3, 23 = 8
73
Number of Child processes created = 2n-1

74

You might also like