Os KCS401 Unit 1
Os KCS401 Unit 1
UNIT – 1 (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.
Examples of Operating System: Windows, Android, iOS, Mac OS, Linux, Window Phone OS, Chrome OS etc.
Definition
• An operating system is a program that controls the execution of application programs and acts as an
interface between the user of a computer and the computer hardware.
• A more common definition is that the operating system is the one program running at all times on the
computer (usually called the kernel), with all else being application programs.
• An operating system is concerned with the allocation of resources and services, such as memory,
processors, devices, and information. The operating system correspondingly includes programs to manage
these resources, such as a traffic controller, a scheduler, memory management module, I/O programs, and
a file system.
Objectives of Operating system(Goals) – The Operating system has three main Objectives:
1. Convenience: An OS makes a computer more convenient to use.
2. Efficiency: An OS allows the computer system resources to be used in an efficient manner.
3. Ability to Evolve: An OS should be constructed in such a way as to permit the effective development,
testing and introduction of new system functions at the same time without interfering with service.
2. 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. 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.
3. 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.
4. 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.
5. File Management:
A file system is normally organized into directories for easy navigation and usage. 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.
6. Providing interface:
It is used in order that user interface acts with a computer mutually. User interface controls how you input
data and instruction and how information is displayed on screen. The operating system offers two types of the
interface to the user:
1. Graphical-line interface: It interacts with of visual environment to communicate with the computer. It
uses windows, icons, menus and other graphical objects to issues commands.
2. Command-line interface: it provides an interface to communicate with the Computer by typing
commands.
7. Security − By means of password and similar other techniques, it prevents unauthorized access to programs
and data.
8. Control over system performance − Recording delays between request for a service and response from
the system.
9. Job accounting − Keeping track of time and resources used by various jobs and users.
10. Error detecting aids − Production of dumps, traces, error messages, and other debugging and error
detecting aids.
11. Coordination between other software and users − Coordination and assignment of compilers,
interpreters, assemblers and other software to the various users of the computer systems.
1. Enhanced performance
2. Execution of several tasks by different processors concurrently, increases the system's throughput without
speeding up the execution of a single task.
3. If possible, system divides task into many subtasks and then these subtasks can be executed in parallel in
different processors. Thereby speeding up the execution of single tasks.
1. MS-DOS and PC-DOS: When IBM-PC came in the market a new operating system was needed. Then
Microsoft Corporation came up with PC-DOS (Personal Computer Disk Operating System) for the IBM-
PC. Later the same company developed MS-DOS (Microsoft Disk Operating System) a portable version of
PC-DOS, that can run on 8086 family microprocessor. MS-DOS is a command driven system.
As new microprocessors are developed accordingly operating systems are modified and updated. 6.22 is the latest
version of MS-DOS available, but most of the computers are running under, windows 95, 97 and 98.
2. Macintosh: Apple Macintosh users, uses menus and icons rather than commands. Icons are small symbols
that represent commands. Using mouse input device, the user moves a pointer to a word or icon and enters
the selection. This system is slower than command driven system.
1. UNIX: This operating system is written in C Language, which is a high level language. It is less hardware
dependent than the operating system written in low level language. Thus UNIX can easily transport from
one system to another. System is surrounded by the shell, which serves as a programming language and as a
command language interpreter, reading the user commands and interpreting them as requests to execute
certain programs. Around the shell are the utilities such as text processing.
2. ZENIX: is an implementation of UNIX operating system for microcomputers. This type of operating
system is gained capital rapid acceptance, because of its multiprogramming capabilities and many useful
utilities.
9. Multi-process system
A multiprocessing system is one which has more than two processors. The CPUs are added to the system to
increase the computing speed of the system. Each CPU has its own set of registers and main memory. Just
because CPUs are separate, it may happen that one CPU must not have anything to process and may sit idle and
the other may be overloaded with the processes. In such cases, the processes and the resources are shared
dynamically among the processors.
Multiprocessing can be classified as symmetric multiprocessing and asymmetric multiprocessing. In
symmetric multiprocessing, all processors are free to run any process in a system. In Asymmetric
multiprocessing, there is a master-slave relationship among the processors. The master processor is responsible
for allotting the process to slave processors.
If the processor has integrated memory controller then adding processor would increase the amount of
addressable memory in the system. Multiprocessing can change the memory access model from uniform
memory access to nonuniform memory access. The uniform memory access amounts the same time for
accessing any RAM from any Processor. On the other hands, non-uniform memory access amounts longer time to
access some part of memory than the other parts.
Multithreading is the execution of multiple threads of a single process concurrently within the context of that
process. Now let us first discuss what is a thread? A thread of a process means a code segment of a process,
which has its own thread ID, program counter, registers and stack and can execute independently. But threads
belonging to the same process has to share the belongings of that process like code, data, and system resources.
Creating separate processes for each service request consumes time and exhaust system resources. Instead of
incurring this overhead, it is more efficient to create threads of a process.
To understand the multithreading concept let us take an example of a word processor. A word processor, displays
graphic, responds to keystrokes, and at the same time, it continues spelling and grammar checking. You do not
have to open different word processors to do this concurrently. It does get happen in a single word processor with
the help of multiple threads.
Now let us take into consideration the benefits of multithreading. Multithreading increases the responsiveness as
if one thread of a process is blocked or performing the lengthy operation, the process still continues. The second
benefit of multithreading is resource sharing as several threads of a process share same code and data within the
same address space.
Creating a thread is economical as it shares the code and data of the process to which they belong. So the system
does not have to allocate resources separately for each thread. Multithreading can be increased on
multiprocessing operating system. As multithreading on multiple CPUs increases parallelism.
• Interactive systems may cause extra noise pollution like recognizing the voice in public places.
• These systems are easy to break and get scratched by touching interface.
• Designing complex and nice graphical interactive systems are difficult and take longer time.
• Nowadays some telephone systems are interactive and they record and recognize the voice. But it is
difficult for old aged people to communicate with these systems. These systems are difficult to design and
perform inaccurately.
• Text to speech is another type of interactive system in which user interacts by inputting text. Some text
cannot be converted as we pronounce it due to culture difference. The real-time text of the speech is
difficult to understand and requires highly skilled people for voice over.
• During receiving calls of customers, text to speech software needs to be accurate to respond and if the
customer takes interest in product then guiding him to the accurate path is difficult to manage and may
involve live representative to talk.
• Automatic calls are also managed by interactive systems. Sometimes people are busy with their work and
when receiving automatic calls make them insecure. These calls are made by company computers for
campaigns which sometimes result in bad result.
• Some interactive web-based software needs an internet connection to perform which limits access to the
user. Sometimes web-based software needs to put information to the public which effects company
business.
• Some interactive software needs extra hardware and memory resources to perform well.
• In interactive marketing, if a customer has already a product then he will just pass away without taking the
interest.
• Some interactive system cost higher due to its installation and setup, for example, interactive whiteboard.
It also makes bad impact on user’s eyes. The content preparation for the interactive whiteboard is also
tough.
Simple structure:
There are several commercial system that don’t have a well" defined structure such operating systems begins
as small, simple & limited systems and then grow beyond their original scope. MS"DOS is an example of
such system. It was not divided into modules carefully. Another example of limited structuring is the UNIX
operating system.
Layered approach: In the layered approach, the OS is broken into a number of layers (levels) each built on top
of lower layers. The bottom layer (layer o ) is the hardware & top most layer (layer N) is the user interface.
The main advantage of the layered approach is modularity.
• The layers are selected such that each users functions (or operations) & services of only lower layer.
• This approach simplifies debugging & system verification, i.e. the first layer can be debugged without
concerning the rest of the system. Once the first layer is debugged, its correct functioning is assumed
while the 2nd layer is debugged & so on.
• If an error is found during the debugging of a particular layer, the error must be on that layer because the
layers below it are already debugged. Thus the design & implementation of the system are simplified
when the system is broken down into layers.
• Each layer is implemented using only operations provided by lower layers. A layer doesn’t need to know
how these operations are implemented; it only needs to know what these operations do.
• The layer approach was first used in the operating system. It was defined in six layers.
Layers Functions
5 User Program
4 I/O Management
3 Operator Process Communication
2 Memory Management
1 CPU Scheduling
0 Hardware
System Components
1. Process Management: A process is only ONE instant of a program in execution. There are many processes
can be running the same program. The five major activities of an operating system in regard to process
management are:
• Creation and deletion of user and system processes.
• Suspension and resumption of processes.
• A mechanism for process synchronization.
• A mechanism for process communication.
• A mechanism for deadlock handling.
2. Main-Memory Management: Main-Memory is a large array of words or bytes. Each word or byte has its
own address. Main memory is a repository of quickly accessible data shared by the CPU and I/O devices. The
major activities of an operating system in regard to memory-management are:
• Keep track of which part of memory are currently being used and by whom.
• Decide which processes are loaded into memory when memory space becomes available.
• Allocate and deallocate memory space as needed.
3. File Management: A file is a collected of related information defined by its creator. Computer can store files
on the disk (secondary storage), which provide long term storage.
• The creation and deletion of files.
• The creation and deletion of directions.
• The support of primitives for manipulating files and directions.
• The mapping of files onto secondary storage.
• The backup of files on stable storage media.
4. I/O System Management: One of the purposes of an operating system is to hide the peculiarities of specific
hardware devices from the user.
• Secondary-Storage Management Generally speaking, systems have several levels of storage, including
primary storage, secondary storage and cache storage. Instructions and data must be placed in primary storage or
cache to be referenced by a running program.
5. Networking A distributed system is a collection of processors that do not share memory, peripheral devices, or
a clock. The processors communicate with one another through communication lines called network.
6. Protection System Protection refers to mechanism for controlling the access of programs, processes, or users
to the resources defined by a computer system.
7. Command Interpreter System A command interpreter is an interface of the operating system with the user.
The user gives commands with are executed by operating system (usually by turning them into system calls).
Operating System Services:
An operating system provides an environment for the execution of the program. It provides some services to the
programs. The various services provided by an operating system are as follows:
1. Program Execution: The system must be able to load a program into memory and to run that program.
The program must be able to terminate this execution either normally or abnormally.
2. I/O Operation: A running program may require I/O. This I/O may involve a file or a I/O device for
specific device. Some special function can be desired. Therefore the operating system must provide a
means to do I/O.
3. File System Manipulation: The programs need to create and delete files by name and read and write
files. Therefore the operating system must maintain each and every files correctly.
4. Communication: The communication is implemented via shared memory or by the technique of message
passing in which packets of information are moved between the processes by the operating system.
5. Error detection: The operating system should take the appropriate actions for the occurrences of any type
like arithmetic overflow, access to the illegal memory location and too large user CPU time.
6. Research Allocation: When multiple users are logged on to the system the resources must be allocated to
each of them. For current distribution of the resource among the various processes the operating system
uses the CPU scheduling run times which determine which process will be allocated with the resource.
7. Accounting: The operating system keep track of which users use how many and which kind of computer
resources.
8. Protection: The operating system is responsible for both hardware as well as software protection. The
operating system protects the information stored in a multiuser computer system.
Kernal: A kernel is an important part of an OS that manages system resources. It also acts as a bridge/
interface between the software and hardware or operating system and central processing unit of the computer. It is
one of the first program which is loaded on start-up after the bootloader. The Kernel is also responsible for
offering secure access to the machine's hardware for various programs. It manages various services as input and
output management, handling various call made to the system known as system calls, etc. It also decides when and
how long a certain application uses specific hardware.
Types of Kernel:
Currently in use are only two types of the kernel which are a microkernel and monolithic kernel.
1. Microkernel:
A microkernel is a software or a program in which user services and kernel services are present in different
address space. Due to which the size of the microkernel becomes smaller than that of a monolithic kernel. But as
the user services and kernel services are in different address space in order for a user service to use a kernel
service, message passing was used. This makes the execution of microkernel to be slower.
The microkernel is easily extendible. Due to which if a new service has to be added then it would not require any
changes to the kernel itself. Also, if any user service crashes it doesn’t affect the working of the microkernel.
The examples of microkernel would be QNX, minix, Symbian, Mac OS X, L4Linux, Integrity, K42, etc.
2. Monolithic kernel:
A monolithic kernel is an operating system software framework that holds all privileges to access input/output
(I/O) devices, memory, hardware interrupts and the CPU stack. A monolithic kernel is program or a software in
which kernel services and user services are present in the same address space. So in order for a user services to
use any kernel services, a system call is used. It makes the execution of the monolithic kernel much faster than the
microkernel. Also, the size of the monolithic kernel is much larger than that of a microkernel. Which makes the
size of the operating system even larger.
Monolithic kernel is not easily extendible, because the user services and kernel services are present in same addess
space. So in order to add any service, changes have to be made in the entire kernel itself. But, the major drawback
of the monolithic kernel is if a user service crashes, it may crash the whole system.
Examples of the monolithic kernel are Microsoft Windows, Linux, BSD (OpenBSD, NetBSD, FreeBSD), Solaris,
DOS, OpenVMS, etc.
Basic It is a large process running in a single address It can be broken down into separate
space processes called servers.
Code In order to write a monolithic kernel, less code is In order to write a microkernel, more
required. code is required
Security If a service crashes, the whole system collapses in a If a service crashes, it never affects the
monolithic kernel. working of a microkernel.
Example Linux, BSDs, Microsoft Windows (95,98, Me), L4Linux, QNX, SymbianK42, Mac OS
Solaris, OS-9, AIX, DOS, XTS-400, etc. X, Integrity, etc.
Kernel pre-emption
Kernel pre-emption does not help in the overall throughput of the system. Instead, it seeks for better responsiveness.
The idea here is that normally kernel functions are only interrupted by hardware causes: Either external interrupts, or IO
wait cases, where it voluntarily gives away control to the scheduler. A pre-emptive kernel instead also interrupts and
suspends kernel functions just like it would interrupt processes in user mode. The system is more responsive, as processes
e.g. handling mouse input, are woken up even while heavy work is done inside the kernel.
Pre-emption on kernel level makes things harder for the kernel developer: The kernel function cannot be suspended only
voluntarily or by interrupt handlers (which are somewhat a controlled environment), but also by any other process due to the
scheduler. Care has to be taken to e.g. avoid deadlocks: A thread locks resource A but needing resource B is interrupted by
another thread which locks resource B, but then needs resource A.
Reentrant Kernels: A reentrant kernel is one that consists of executable code (programs and data) stored in
memory such that several processes can use this code at the same time without hindering the working of other
processes. Thus in reentrant kernel several processes may be executing in kernel mode at the same time.
For example:- a Process ‘A’ wants to perform read operation on disc, then the kernel will send this request to
disc controller. The disc controller will handle this read operation request and kernel will assign CPU to some
other process ‘B’ . When the process ‘A’ read operation is completed, the interrupt will notify the kernel so the
process ‘A’ can resume the execution. A typical use case is IO wait
The different concurrently processes executing in kernel made also share data. The data modified by one process
will affect the functioning of other processes using the data, so to avoid this condition a reentrant kernel uses
reentrant functions and locking mechanism. Reentrant functions are the one which allow process to modify only
the local variables and do not affect the global data variables. In locking mechanism, several processes can
execute reentrant function concurrently but only one process at a time can execute non-reetrant function. Once
that process is done then only other process can execute non reentrant function. This will ensure that global data
is modified by only one process at a time and thus each process has same copy of global data being shared among
them. In other words, by using locking mechanism there will be no chance of data corruption or multiple copies
of global data. Unix is a good example of reentrant kernel.
Spooling: Suppose we have a printer connected to a machine. Many users may seek to use the printer. To
avoid print clashes, it is important to be able to queue up all the print requests. This is achieved by spooling. The
OS maintains all print requests and schedules each users' print requests. In other words, all output commands to
print are intercepted by the OS kernel. An area is used to spool the output so that a users' job does not have to
wait for the printer to be available.