Operating Systems Part - 1/5
Operating Systems Part - 1/5
Introduction:
An Operating System (OS) is an interface between a computer user and computer
hardware. An operating system is a software which performs all the basic tasks like file
management, memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers.
Some popular Operating Systems include Linux Operating System, Windows
Operating System, VMS, OS/400, AIX, z/OS, etc.
Definition
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
Memory Management
Processor Management
Device Management
File Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software and users
1. Memory Management
Memory management refers to management of Primary Memory or Main Memory.
Main memory is a large array of words or bytes where each word or byte has its own
address.
Main memory provides a fast storage that can be accessed directly by the CPU. For a
program to be executed, it must in the main memory. An Operating System does the
following activities for memory management −
Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part
are not in use.
In multiprogramming, the OS decides which process will get memory when and how
much.
Allocates the memory when a process requests it to do so.
De-allocates the memory when a process no longer needs it or has been terminated.
2. Processor Management
In multiprogramming environment, the OS decides which process gets the processor when
and for how much time. This function is called process scheduling. An Operating System
does the following activities for processor management −
Keeps tracks of processor and status of process. The program responsible for this task
is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
3. Device Management
An Operating System manages device communication via their respective drivers. It does
the following activities for device management −
Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
4. File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions.
An Operating System does the following activities for file management −
Keeps track of information, location, uses, status etc. The collective facilities are
often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Problem of reliability.
Question of security and integrity of user programs and data.
Problem of data communication.
An Operating System provides services to both the users and to the programs.
Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
1. 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 −
It is better that operating systems have a modular structure, unlike MS-DOS. That would lead
to greater control over the computer system and its various applications. The modular structure would
also allow the programmers to hide information as required and implement internal routines as they
see fit without changing the outer specifications.
The operating system can be implemented with the help of various structures. The
structure of the OS depends mainly on how the various common components of the operating
system are interconnected and melded into the kernel. Depending on this, we have to follow
the structures of the operating system.
The layered structure approach breaks up the operating system into different layers and
retains much more control on the system. The bottom layer (layer 0) is the hardware, and the
topmost layer (layer N) is the user interface. These layers are so designed that each layer uses
the functions of the lower-level layers only. It simplifies the debugging process as if lower-
level layers are debugged, and an error occurs during debugging. The error must be on that
layer only as the lower-level layers have already been debugged.
o This allows implementers to change the inner workings and increases modularity.
o As long as the external interface of the routines doesn't change, developers have more
freedom to change the inner workings of the routines.
o The main advantage is the simplicity of construction and debugging. The main
difficulty is defining the various layers.
The main disadvantage of this structure is that the data needs to be modified and passed
on at each layer, which adds overhead to the system. Moreover, careful planning of the layers
is necessary as a layer can use only lower-level layers. UNIX is an example of this structure.
There are six layers in the layered operating system.
A diagram demonstrating these layers is as follows:
1. Hardware: This layer interacts with the system hardware and coordinates with all the peripheral
devices used, such as a printer, mouse, keyboard, scanner, etc. These types of hardware devices are
managed in the hardware layer.
The hardware layer is the lowest and most authoritative layer in the layered operating
system architecture. It is attached directly to the core of the system.
2. CPU Scheduling: This layer deals with scheduling the processes for the CPU. Many scheduling
queues are used to handle processes. When the processes enter the system, they are put into the job
queue.
The processes that are ready to execute in the main memory are kept in the ready queue.
This layer is responsible for managing how many processes will be allocated to the CPU and how many
will stay out of the CPU.
3. Memory Management: Memory management deals with memory and moving processes from disk
to primary memory for execution and back again. This is handled by the third layer of the operating
system. All memory management is associated with this layer. There are various types of memories in
the computer like RAM, ROM.
If you consider RAM, then it is concerned with swapping in and swapping out of memory. When
our computer runs, some processes move to the main memory (RAM) for execution, and when
programs, such as calculator, exit, it is removed from the main memory.
4. Process Management: This layer is responsible for managing the processes, i.e., assigning the
processor to a process and deciding how many processes will stay in the waiting schedule. The priority
of the processes is also managed in this layer. The different algorithms used for process scheduling are
FCFS (first come, first served), SJF (shortest job first), priority scheduling, round-robin scheduling, etc.
5. I/O Buffer: I/O devices are very important in computer systems. They provide users with
the means of interacting with the system. This layer handles the buffers for the I/O devices and makes
sure that they work correctly.
Suppose you are typing from the keyboard. There is a keyboard buffer attached with the
keyboard, which stores data for a temporary time. Similarly, all input/output devices have some buffer
attached to them. This is because the input/output devices have slow processing or storing speed. The
computer uses buffers to maintain the good timing speed of the processor and input/output devices.
6. User Programs: This is the highest layer in the layered operating system. This layer deals
with the many user programs and applications that run in an operating system, such as word processors,
games, browsers, etc. You can also call this an application layer because it is concerned with
application programs.
Advantages of Layered Structure
There are several advantages of the layered structure of operating system design, such as:
1. Modularity: This design promotes modularity as each layer performs only the tasks it is scheduled to
perform.
2. Easy debugging: As the layers are discrete so it is very easy to debug. Suppose an error occurs in the
CPU scheduling layer. The developer can only search that particular layer to debug, unlike the
Monolithic system where all the services are present.
3. Easy update: A modification made in a particular layer will not affect the other layers.
4. No direct access to hardware: The hardware layer is the innermost layer present in the design. So a
user can use the services of hardware but cannot directly modify or access it, unlike the Simple system
in which the user had direct access to the hardware.
5. Abstraction: Every layer is concerned with its functions. So the functions and implementations of the
other layers are abstract to it.
Memory Management
Memory management plays an important part in operating system. It deals with memory and
the moving of processes from disk to primary memory for execution and back again.
The activities performed by the operating system for memory management are −
The operating system assigns memory to the processes as required. This can be done
using best fit, first fit and worst fit algorithms.
All the memory is tracked by the operating system i.e. it nodes what memory parts are
in use by the processes and which are empty.
The operating system deallocated memory from processes as required. This may
happen when a process has been terminated or if it no longer needs the memory.
Device Management
There are many I/O devices handled by the operating system such as mouse, keyboard, disk
drive etc. There are different device drivers that can be connected to the operating system to
handle a specific device. The device controller is an interface between the device and the
device driver. The user applications can access all the I/O devices using the device drivers,
which are device specific codes.
File Management
Files are used to provide a uniform view of data storage by the operating system. All the files
are mapped onto physical devices that are usually non volatile so data is safe in the case of
system failure.
The files can be accessed by the system in two ways i.e. sequential access and direct access −
Sequential Access
The information in a file is processed in order using sequential access. The files
records are accessed on after another. Most of the file systems such as editors,
compilers etc. use sequential access.
Direct Access
In direct access or relative access, the files can be accessed in random for read and
write operations. The direct access model is based on the disk model of a file, since it
allows random accesses.
Computing environments;
Computing is nothing but process of completing a task by using this computer
technology and it may involve computer hardware and/or software. But computing uses
some form of computer system to manage, process, and communicate information. After
getting some idea about computing now lets understand about computing environments.
ComputingEnvironments:
When a problem is solved by the computer, during that computer uses many
devices, arranged in different ways and which work together to solve problems. This
constitutes a computing environment where various number of computer devices arranged
in different ways to solve different types of problems in different ways. In different
computing environments computer devices are arranged in different ways and they
exchange information in between them to process and solve problem. One computing
environment consists of many computers other computational devices, software and
networks that to support processing and sharing information and solving task.
Based on the organization of different computer devices and communication processes
there exists multiple types of computing environments. Now lets know about different
types of computing environments.
Open Source operating systems are released under a license where the copyright
holder allows others to study, change as well as distribute the software to other people. This
can be done for any reason. The different open source operating system available in the
market are −
Cosmos
This is an open source operating system written mostly in programming language C#. Its full
form is C# Open Source Managed Operating System.
FreeDOS
This was a free operating system developed for systems compatible with IBM PC computers.
FreeDOS provides a complete environment to run legacy software and other embedded
systems.
Genode
Genode is free as well as open source. It contains a microkernel layer and different user
components. It is one of the few open source operating systems not derived from a licenced
operating system such as Unix.
Ghost OS
This is a free, open source operating system developed for personal computers. It started as a
research project and developed to contain various advanced features like graphical user
interface, C library etc.
ITS
The incompatible time-sharing system was developed by the MIT Artificial Intelligence
Library. It is principally a time sharing system. There is a remote login facility which allowed
guest users to informally try out the operating system and its features using ARPAnet.
OSv
This was an operating system released in 2013. It was mainly focused on cloud computing
and was built to run on top of a virtual machine as a guest. This is the reason it doesn't
include drivers for bare hardware.
Phantom OS
This is an operating system that is based on the concepts on persistent virtual memory and is
code oriented. It was mostly developed by Russian developers. Phantom OS is not based on
concepts of famous operating systems such as Unix.
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 −
Loads a program into memory.
Executes the program.
Handles program's execution.
Provides a mechanism for process synchronization.
Provides a mechanism for process communication.
Provides a mechanism for deadlock handling.
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software.
Drivers hide the peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
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 −
Two processes often require data to be transferred between them
Both the processes can be on one computer or on different computers, but are
connected through a computer network.
Communication may be implemented by two methods, either by Shared Memory or
by Message Passing.
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 −
The OS constantly checks for possible errors.
The OS takes an appropriate action to ensure correct and consistent computing.
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 −
The OS manages all kinds of resources using schedulers.
CPU scheduling algorithms are used for better utilization of CPU.
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.
A user interface of any operating system can be classified into one of the following types:
The GUI interface is easy to understand and even the new users can operate on them on their
own.
The GUI interface visually acknowledges and confirms each type of activities performed by
the users. For example when the user deletes a file in the Windows operating system, then the
operating system asks for the confirmation before deleting it.
The GUI interface enables the users to perform a number of tasks at the same time. This
features of the operating system are also known as multitasking.
Example: In order to perform a task, we need to type a command at the command prompt
denoted by C:\> to copy a text file, say al.text, from the C drive of our computer system. To
the D drive, we need to type the copy command at the command prompt.
SYSTEM CALL:
System Call: A system call is a way for a user program to interface with the operating system. The
program requests several services, and the OS responds by invoking a series of system calls to satisfy
the request. A system call can be written in assembly language or a high-level language
like C or Pascal. System calls are predefined functions that the operating system may directly invoke
if a high-level language is used.
A system call is a method for a computer program to request a service from the kernel of
the operating system on which it is running. A system call is a method of interacting with the
operating system via programs. A system call is a request from computer software to an operating
system's kernel.
There are various situations where you must require system calls in the operating system.
Following of the situations are as follows:
1. It is must require when a file system wants to create or delete a file.
2. Network connections require the system calls to sending and receiving data packets.
3. If you want to read or write a file, you need to system calls.
4. If you want to access hardware devices, including a printer, scanner, you need a
system call.
5. System calls are used to create and manage new processes.
open()
The open() system call allows you to access a file on a file system. It allocates
resources to the file and provides a handle that the process may refer to. Many processes can
open a file at once or by a single process only. It's all based on the file system and structure.
read()
It is used to obtain data from a file on the file system. It accepts three arguments in
general:
o A file descriptor.
o A buffer to store read data.
o The number of bytes to read from the file.
wait()
In some systems, a process may wait for another process to complete its execution.
This happens when a parent process creates a child process and the execution of the parent
process is suspended until the child process executes.
exec()
This system call runs an executable file in the context of an already running process.
It replaces the previous executable file.
fork()
Processes use the fork() system call to create processes that are a copy of themselves.
This is one of the major methods of process creation in operating systems. When a parent
process creates a child process and the execution of the parent process is suspended until the
child process executes.
exit()
The exit() system call is used by a program to terminate its execution. In a
multithreaded environment, this means that the thread execution is complete.
kill()
The kill() system call is used by the operating system to send a termination signal to a
process that urges the process to exit.
System Programs
System programs provide an environment where programs can be developed and
executed. In the simplest sense, system programs also provide a bridge between the user
interface and system calls. In reality, they are much more complex. For example, a compiler
is a complex system program.
System Boot
Booting is the process of starting a computer. It can be initiated by hardware such as a
button press or by a software command. After it is switched on, a CPU has no software in its
main memory, so some processes must load software into memory before execution. This
may be done by hardware or firmware in the CPU
or by a separate processor in the computer system.
Restarting a computer also is called rebooting, which can be "hard", e.g., after
electrical power to the CPU is switched from off to on, or "soft", where the power is not cut.
On some systems, a soft boot may optionally clear RAM to zero. Hard and soft booting can
be initiated by hardware such as a button press or a software command.
Booting Process in Operating System
When our computer is switched on, it can be started by hardware such as a button press, or by
software command, a computer's central processing unit (CPU) has no software in its main
memory, there is some process which must load software into main memory before it can be
executed. Below are the six steps to describe the boot process in the operating system, such
as:
Step 1: Once the computer system is turned on, BIOS (Basic Input /Output System) performs
a series of activities or functionality tests on programs stored in ROM, called
on POST (Power-on Self Test) that checks to see whether peripherals in the system are in
perfect order or not.
Step 2: After the BIOS is done with pre-boot activities or functionality test, it read bootable
sequence from CMOS (Common Metal Oxide Semiconductor) and looks for master boot
record in the first physical sector of the bootable disk as per boot device sequence specified
in CMOS. For example, if the boot device sequence is:
o Floppy Disk
o Hard Disk
o CDROM
Step 3: After this, the master boot record will search first in a floppy disk drive
. If not found, then the hard disk drive will search for the master boot record. But if the
master boot record is not even present on the hard disk, then the CDROM drive will search. If
the system cannot read the master boot record from any of these sources, ROM displays "No
Boot device found" and halted the system. On finding the master boot record from a
particular bootable disk drive, the operating system loader, also called Bootstrap loader, is
loaded from the boot sector of that bootable drive· into memory. A bootstrap loader is a
special program that is present in the boot sector of a bootable drive.
Step 4: The bootstrap loader first loads the IO.SYS file. After this, MSDOS.SYS file is
loaded, which is the core file of the DOS operating system.
Step 6: The last file is to be loaded and executed is the AUTOEXEC.BAT file that contains a
sequence of DOS commands. After this, the prompt is displayed. We can see the drive letter
of bootable drive displayed on the computer system, which indicates that the operating
system has been successfully on the system from that drive.