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

3_OS_Module1

The document provides an overview of operating systems, detailing their key functions such as process management, memory management, file management, I/O system management, secondary storage management, and protection systems. It also discusses various types of operating systems including batch, multiprogramming, time-sharing, distributed, virtualization, real-time embedded systems, and open-source operating systems, along with their advantages and disadvantages. Additionally, it explains system calls and the modes of operation (kernel and user mode) within an operating system.

Uploaded by

zoya.23bce9358
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

3_OS_Module1

The document provides an overview of operating systems, detailing their key functions such as process management, memory management, file management, I/O system management, secondary storage management, and protection systems. It also discusses various types of operating systems including batch, multiprogramming, time-sharing, distributed, virtualization, real-time embedded systems, and open-source operating systems, along with their advantages and disadvantages. Additionally, it explains system calls and the modes of operation (kernel and user mode) within an operating system.

Uploaded by

zoya.23bce9358
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Operating Systems

CSE-2007

1
Operating system operations
• Process Management
• Main Memory Management
• File Management
• I/O System Management
• Secondary Management
• Protection System
• Command-Interpreter System

2
Process Management
• A process is a program in execution. A process needs
certain resources, including CPU time, memory, files, and
I/O devices, to accomplish its task.
• The operating system is responsible for the following
activities in connection with process management.
 Process creation and deletion.
 process suspension and resumption.
 Provision of mechanisms for:
process synchronization
process communication

3
Main Memory Management
• Memory is a large array of words or bytes, each with its
own address. It is a repository of quickly accessible data
shared by the CPU and I/O devices.
• Main memory is a volatile storage device. It loses its
contents in the case of system failure.
• The operating system is responsible for the following
activities in connections with memory management:
 Keep track of which parts of memory are currently
being used and by whom.
 Decide which processes to load when memory space
becomes available (allocation policy)
 Allocate and deallocate memory space as needed.

4
File Management
• A file is a collection of related information defined by its
creator. Commonly, files represent programs (both source
and object forms) and data.
• The operating system is responsible for the following
activities in connections with file management:
 File creation and deletion.
 Directory creation and deletion.
 Support of primitives for manipulating files and
directories.
 Mapping files onto secondary storage.
 File backup on stable (nonvolatile) storage media.

5
I/O System Management
• The I/O system consists of:
A buffer-caching system
A general device-driver interface
Drivers for specific hardware devices
SPOOLing (simultaneous peripheral operations
online) for virtual devices (e.g., a shared printer)

6
Secondary-Storage Management
• Most modern computer systems use disks as the principle
on-line secondary storage medium, for both programs and
data.
 Bulk memory (large size)
 Low cost
 Access time in between DRAM and tapes (variable over
a small range) (1 msec ~ 60mec per 1Kbyte on a single
magnetic disk surface)
• The operating system is responsible for the following
activities in connection with disk management:
 Free space management
 Storage allocation
 Disk scheduling

7
Protection & Security System
• Protection refers to a mechanism for controlling access by
programs, processes, or users to both system and user
resources.
• The protection mechanism must:
 distinguish between authorized and unauthorized usage.
 specify the controls to be imposed.
 provide a means of enforcement.

8
Types of Operating Systems
• Batch O.S.
• Multi programmed O.S.
• Time Sharing O.S.
• Distributed O.S.
• Virtualization
• Real Time Embedded Systems
• Open source O.S.

9
Batch O.S.
• It is the First operating system of the second generation
computer.
• Batch operating system took the input on the punch card.
• Each punch card had the different form of data.
• System executed the jobs one by one in batch.
• When one job from the batch executed, then the second job has
taken from it and so on.
• The process of placing the jobs in queue for execution is known
as spooling.

10
Batch O.S.
• The batch processing system used where we want to update the data related
to any transactions or any record.

• Transactions can be related to any customer orders, receipts, invoices,


payments, online transactions, data entry, payroll system, banks etc.

11
Pros and Cons of Batch OS
Advantages of Batch Operating System:
 It is very difficult to guess or know the time required for any job to
complete. Processors of the batch systems know how long the job
would be when it is in queue
 Multiple users can share the batch systems
 The idle time for the 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
 Batch systems are hard to debug
 It is sometimes costly
 The other jobs will have to wait for an unknown time if any job fails

12
Multi programmed O.S.
• Multiprogramming OS is an ability of an operating
system that executes more than one program using a single
processor machine.
• More than one task or program or jobs are present inside
the main memory at one point of time.
• Buffering and spooling can overlap I/O and CPU tasks to
improve the system performance but it has some
limitations that a single user cannot always keep CPU or
I/O busy all the time.

13
Multi programmed O.S.

14
Types of the
Multiprogramming Operating
System
There are mainly two types of multiprogramming operating
systems. These are as follows:

1. Multitasking Operating System


2. Multiuser Operating System

15
Multiprogramming Operating
System
Multitasking Operating System
• A multitasking operating system enables the execution of two or more
programs at the same time. The operating system accomplishes this by
shifting each program into and out of memory one at a time. When a program
is switched out of memory, it is temporarily saved on disk until it is required
again.
Multiuser Operating System
• A multiuser operating system allows many users to share processing time on a
powerful central computer from different terminals. The operating system
accomplishes this by rapidly switching between terminals, each of which
receives a limited amount of processor time on the central computer. The
operating system changes among terminals so quickly that each user seems to
have continuous access to the central computer. If there are many users on a
system like this, the time it takes the central computer to reply can become
more obvious.

16
Pros and Cons of Multiprogramming OS
Advantages
1. It provides less response time.
2. It may help to run various jobs in a single application simultaneously.
3. It helps to optimize the total job throughput of the computer.
4. Various users may use the multiprogramming system at once.
5. Short-time jobs are done quickly in comparison to long-time jobs.
6. It may help to improve turnaround time for short-time tasks.
7. It helps in improving CPU utilization and never gets idle.
8. The resources are utilized smartly.
Disadvantages
1. It is highly complicated and sophisticated.
2. The CPU scheduling is required.
3. Memory management is needed in the operating system because all types of
tasks are stored in the main memory.
4. The harder task is to handle all processes and tasks.
5. If it has a large number of jobs, then long-term jobs will require a long wait.
17
Time-Sharing OS
• A time shared operating system uses CPU scheduling and multi-
programming to provide each with a small portion of a shared
computer at once.
• Each user has at least one separate program in memory.
• A program loaded into memory and executes, it performs a short
period of time either before completion or to complete I/O.
• This short period of time during which user gets attention of CPU is
known as time slice, time slot or quantum.
• It is typically of the order of 10 to 100 milliseconds.
• Time shared operating systems are more complex than
multiprogrammed operating systems.
• In both, multiple jobs must be kept in memory simultaneously, so the
system must have memory management and security.

18
Time-Sharing OS

19
Time-Sharing OS
Advantages of Time Sharing Operating System
• The time-sharing operating system provides effective
utilization and sharing of resources.
• This system reduces CPU idle and response time.
Disadvantages of Time Sharing Operating System
• Data transmission rates are very high in comparison to other
methods.
• Security and integrity of user programs loaded in memory
and data need to be maintained as many users access the
system at the same time.

20
Distributed O.S
• Distributed systems use multiple central processors to
serve multiple real-time applications and multiple users.
Data processing jobs are distributed among the processors
accordingly.
• The processors communicate with one another through
various communication lines (such as high-speed buses or
telephone lines). These are referred as loosely coupled
systems or distributed systems.
• Processors in a distributed system may vary in size and
function. These processors are referred as sites, nodes,
computers, and so on.

21
Virtualization

22
Advantages/Disadvantages of
Virtual Machines
• The virtual-machine concept provides complete protection of
system resources since each virtual machine is isolated from all
other virtual machines. This isolation, however, permits no
direct sharing of resources.
• A virtual-machine system is a perfect vehicle for operating-
systems research and development. System development is
done on the virtual machine, instead of on a physical machine
and so does not disrupt normal system operation.
• The virtual machine concept is difficult to implement due to the
effort required to provide an exact duplicate to the underlying
machine.

23
Real Time Embedded Systems
• In Real-Time Systems, each job carries a certain deadline
within which the job is supposed to be completed,
otherwise, the huge loss will be there, or even if the result
is produced, it will be completely useless.
• Often used as a control device in a dedicated application
such as controlling scientific experiments, nuclear reactor,
medical imaging systems, industrial control systems, some
display systems.
• Well-defined fixed-time constraints.
• Real-Time systems may be either hard or soft real-time

24
Types of RTOS
• Real-Time systems may be either hard or soft real-time

• Hard real-time:
 Secondary storage limited or absent, data stored in short term
memory, or read-only memory (ROM)
 Conflicts with time-sharing systems, not supported by general-
purpose operating systems.

• Soft real-time
 Limited utility in industrial control or robotics
 Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features

25
Open Source OS
• The term "open source" refers to computer software or
applications where the owners or copyright holders enable
the users or third parties to use, see, and edit the product's
source code.
• The source code of an open-source OS is publicly visible
and editable.
• The usually operating systems such as Apple's iOS,
Microsoft's Windows, and Apple's Mac OS are closed
operating systems
• The user may modify or change those codes and develop
new applications according to the user requirement.
• Some basic examples of the open-source operating systems
are Linux, Open Solaris, Free RTOS, Open BDS, Free
BSD, Minix, etc.
26
Open Source OS
Advantages
• Reliable and efficient
• Cost-efficient
• Flexibility

Disadvantages
• Complicated
• Security risk
• No support
27
System Call in OS
Every modern operating system supports these two modes.
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.
• That means the system will be in a safe state even if a
program in user mode crashes.
• Hence, most programs in an OS run in user mode.

28
29
System Call in OS
• 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. This is done via something called a 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
which results in change of mode from kernel mode back to
user mode.

30
31
32
Steps in Making a System Call

There are 11 steps in making the system call


read (fd, buffer, nbytes) 33
34
35
36
37
C code for fork() system call
main(){
fork();
fork();
printf(“\n hello world”);
}

38
39
Examples
#include <stdio.h>
#include <unistd.h>
int main() {
if (fork() && fork());
fork();
printf(“Hello\n");
return 0;
}
exec(): This system call is called when the running
process wants to execute another executable file
40
xplanation:

1. It will create two process one parent P (has process ID of child process)and
other is child C1 (process ID = 0).
2. In if statement we used OR operator( || ) and in this case second condition is
evaluated when first condition is false.
3. Parent process P will return positive integer so it directly execute statement
and create two more processes (one parent P and other is child C2). Child
process C1 will return 0 so it checks for second condition and second condition
again create two more processes(one parent C1 and other is child C3).
4. C1 return positive integer so it will further create two more processes (on
parent C1 and other is child C4). Child C3 return 0 so it will directly print 1.
41

You might also like