Operating System Unit 1
Operating System Unit 1
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
Program execution
Operating systems handle many kinds of activities from user programs to
system programs like printer spooler, name servers, file server, etc. Each of
these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use). Following are the major activities
of an operating system with respect to program management −
I/O operation means read or write operation with any file or any
specific I/O device.
Operating system provides the access to the required I/O device
when required.
Communication
In case of distributed systems which are a collection of processors that do
not share memory, peripheral devices, or a clock, the operating system
manages communications between all the processes. Multiple processes
communicate with one another through communication lines in the network.
The OS handles routing and connection strategies, and the problems of
contention and security. Following are the major activities of an operating
system with respect to communication −
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O
devices or in the memory hardware. Following are the major activities of an
operating system with respect to error handling −
Resource Management
In case of multi-user or multi-tasking environment, resources such as main
memory, CPU cycles and files storage are to be allocated to each user or job.
Following are the major activities of an operating system with respect to
resource management −
Protection
Considering a computer system having multiple users and concurrent
execution of multiple processes, the various processes must be protected
from each other's activities.
Protection refers to a mechanism or a way to control the access of programs,
processes, or users to the resources defined by a computer system.
Following are the major activities of an operating system with respect to
protection −
The OS ensures that all access to system resources is controlled.
The OS ensures that external I/O devices are protected from
invalid access attempts.
The OS provides authentication features for each user by means
of passwords.
System Calls:
In computing, a system call 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 :
1. Process creation and management
2. Main memory management
3. File Access, Directory and File system management
4. Device handling(I/O)
5. Protection
6. Networking, etc.
Types of System Calls : There are 5 different categories of system calls
–
1. Process control: end, abort, create, terminate, allocate and
free memory.
2. File management: create, open, close, delete, read file etc.
3. Device management
4. Information maintenance
5. Communication
Examples of Windows and Unix System Calls –
Windows Unix
CreateProcess() fork()
ExitProcess() exit()
Process Control WaitForSingleObject() wait()
SetConsoleMode() ioctl()
ReadConsole() read()
Device Manipulation WriteConsole() write()
GetCurrentProcessID() getpid()
SetTimer() alarm()
Information Maintenance Sleep() sleep()
CreatePipe() pipe()
CreateFileMapping() shmget()
Communication MapViewOfFile() mmap()
SetFileSecurity() chmod()
InitlializeSecurityDescriptor() umask()
Protection SetSecurityDescriptorGroup() chown()
System programs:
What are system programs with example?
System software is software designed to provide a platform for other software.
Examples of system software include operating systems (OS) like macOS, Linux,
Android and Microsoft Windows, computational science software, game engines,
search engines, industrial automation, and software as a service applications.
System structure:
Simple Structure
There are many operating systems that have a rather simple structure.
These started as small systems and rapidly expanded much further than
their scope. A common example of this is MS-DOS. It was designed simply
for a niche amount for people. There was no indication that it would become
so popular.
An image to illustrate the structure of MS-DOS is as follows −
Layered Structure
One way to achieve modularity in the operating system is the layered
approach. In this, the bottom layer is the hardware and the topmost layer is
the user interface.
An image demonstrating the layered approach is as follows −
As seen from the image, each upper layer is built on the bottom layer. All
the layers hide some structures, operations etc from their upper layers.
One problem with the layered structure is that each layer needs to be
carefully defined. This is necessary because the upper layers can only use
the functionalities of the layers below them.
User Goals
The operating system should be convenient, easy to use, reliable, safe and
fast according to the users. However, these specifications are not very
useful as there is no set method to achieve these goals.
System Goals
The operating system should be easy to design, implement and maintain.
These are specifications required by those who create, maintain and operate
the operating system. But there is not specific method to achieve these
goals as well.
Operating System Mechanisms and Policies
There is no specific way to design an operating system as it is a highly
creative task. However, there are general software principles that are
applicable to all operating systems.
A subtle difference between mechanism and policy is that mechanism shows
how to do something and policy shows what to do. Policies may change over
time and this would lead to changes in mechanism. So, it is better to have a
general mechanism that would require few changes even when a policy
change occurs.
For example - If the mechanism and policy are independent, then few
changes are required in mechanism if policy changes. If a policy favours I/O
intensive processes over CPU intensive processes, then a policy change to
preference of CPU intensive processes will not change the mechanism.
System generation:
The First Generation ( 1945 - 1955 ): Vacuum Tubes
and Plugboards
Digital computers were not constructed until the second world war.
Calculating engines with mechanical relays were built at that time. However,
the mechanical relays were very slow and were later replaced with vacuum
tubes. These machines were enormous but were still very slow.
These early computers were designed, built and maintained by a single
group of people. Programming languages were unknown and there were no
operating systems so all the programming was done in machine language.
All the problems were simple numerical calculations.
By the 1950’s punch cards were introduced and this improved the computer
system. Instead of using plugboards, programs were written on cards and
read into the system.