UNIT_1_OS
UNIT_1_OS
An Operating System (OS) is a collection of software that manages computer hardware resources and
provides common services for computer programs. When you start using a Computer System then
it's the Operating System (OS) which acts as an interface between you and the computer hardware.
The operating system is really a low level Software which is categorised as a System Software and
supports a computer's basic functions, such as memory management, tasks scheduling and
controlling peripherals etc.
This simple and easy tutorial will take you through step by step approach while learning Operating
System concepts in detail.
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.
Computer Users are the users who use the overall computer system.
Application Softwares are the softwares which users use directly to perform different
activities. These softwares are simple and easy to use like Browsers, Word, Excel, different
Editors, Games etc. These are usually written in high-level languages, such as Python, Java
and C++.
System Softwares are the softwares which are more complex in nature and they are more
near to computer hardware. These software are usually written in low-level languages like
assembly language and includes Operating Systems (Microsoft Windows, macOS, and Linux),
Compiler, and Assembler etc.
There are plenty of Operating Systems available in the market which include paid and unpaid (Open
Source). Following are the examples of the few most popular Operating Systems:
Windows: This is one of the most popular and commercial operating systems developed and
marketed by Microsoft. It has different versions in the market like Windows 8, Windows 10
etc and most of them are paid.
Linux This is a Unix based and the most loved operating system first released on September
17, 1991 by Linus Torvalds. Today, it has 30+ variants available like Fedora, OpenSUSE,
CentOS, UBuntu etc. Most of them are available free of charges though you can have their
enterprise versions by paying a nominal license fee.
MacOS This is again a kind of Unix operating system developed and marketed by Apple Inc.
since 2001.
iOS This is a mobile operating system created and developed by Apple Inc. exclusively for its
mobile devices like iPhone and iPad etc.
Android This is a mobile Operating System based on a modified version of the Linux kernel
and other open source software, designed primarily for touchscreen mobile devices such as
smartphones and tablets.
Some other old but popular Operating Systems include Solaris, VMS, OS/400, AIX, z/OS, etc.
It keeps track of primary memory, i.e., which bytes of memory are used by which user
program. The memory addresses that have already been allocated and the memory
addresses of the memory that has not yet been used.
In multiprogramming, the OS decides the order in which processes are granted memory
access, and for how long.
It Allocates the memory to a process when the process requests it and deallocates the
memory when the process has terminated or is performing an I/O operation.
Processor Management
An operating system manages the processor’s work by allocating various jobs to it and ensuring that
each process receives enough time from the processor to function properly.
Keeps track of the status of processes. The program which performs this task is known as a traffic
controller. Allocates the CPU that is a processor to a process. De-allocates processor when a process
is no longer required.
Device Management
An OS manages device communication via its respective drivers. It performs the following activities
for device management.
Keeps track of all devices connected to the system. Designates a program responsible for
every device known as the Input/Output controller.
Decide which process gets access to a certain device and for how long.
Allocates devices effectively and efficiently. Deallocates devices when they are no longer
required.
There are various input and output devices. An OS controls the working of these input-
output devices.
It receives the requests from these devices, performs a specific task, and communicates back
to the requesting process.
File Management
A file system is organized into directories for efficient or easy navigation and usage. These directories
may contain other directories and other files. An Operating System carries out the following file
management activities. It keeps track of where information is stored, user access settings, the status
of every file, and more. These facilities are collectively known as the file system. An OS keeps track of
information regarding the creation, deletion, transfer, copy, and storage of files in an organized way.
It also maintains the integrity of the data stored in these files, including the file directory structure,
by protecting against unauthorized access.
2. It performs basic computer tasks e.g. managing the various peripheral devices e.g. mouse,
keyboard.
3. It provides a user interface, e.g. command line, graphical user interface (GUI)
4. It handles system resources such as computer's memory and sharing of the central processing
unit(CPU) time by various applications or peripheral devices.
5. It provides file management which refers to the way that the operating system manipulates,
stores, retrieves and saves data.
6. Error Handling is done by the operating system. It takes preventive measures whenever required
to avoid errors.
Program vs Process
int main() {
printf("Hello, World! \n");
return 0;
}
A part of a computer program that performs a well-defined task is known as
an algorithm. A collection of computer programs, libraries and related data are
referred to as a software.
Process
A process is basically a program in execution. The execution of a process must
progress in a sequential fashion.
A process is defined as an entity which represents the basic unit of work to be
implemented in the system.
To put it in simple terms, we write our computer programs in a text file and
when we execute this program, it becomes a process which performs all the
tasks mentioned in the program.
When a program is loaded into the memory and it becomes a process, it can be
divided into four sections ─ stack, heap, text and data. The following image
shows a simplified layout of a process inside main memory −
Stack
The process Stack contains the temporary data such as method/function
parameters, return address and local variables.
Heap
This is dynamically allocated memory to a process during its run time.
Text
This includes the current activity represented by the value of Program Counter and
the contents of the processor's registers.
Data
This section contains the global and static variables.
Start
This is the initial state when a process is first started/created.
Ready
The process is waiting to be assigned to a processor. Ready processes are waiting to
have the processor allocated to them by the operating system so that they can run.
Process may come into this state after Start state or while running it by but
interrupted by the scheduler to assign CPU to some other process.
Running
Once the process has been assigned to a processor by the OS scheduler, the process
state is set to running and the processor executes its instructions.
Waiting
Process moves into the waiting state if it needs to wait for a resource, such as
waiting for user input, or waiting for a file to become available.
Terminated or Exit
Once the process finishes its execution, or it is terminated by the operating system,
it is moved to the terminated state where it waits to be removed from main
memory.
The PCB is maintained for a process throughout its lifetime, and is deleted once the
process terminates.
Process State
The current state of the process i.e., whether it is ready, running, waiting, or
whatever.
Process privileges
This is required to allow/disallow access to system resources.
Process ID
Unique identification for each of the process in the operating system.
Pointer
A pointer to parent process.
Program Counter
Program Counter is a pointer to the address of the next instruction to be executed
for this process.
CPU registers
Various CPU registers where process need to be stored for execution for running
state.
Accounting information
This includes the amount of CPU used for process execution, time limits,
execution ID etc.
IO status information
This includes a list of I/O devices allocated to the process.
Categories of Scheduling
There are two categories of scheduling:
1. Non-preemptive: Here the resource can’t be taken from a process until the process
completes execution. The switching of resources occurs when the running process
terminates and moves to a waiting state.
2. Preemptive: Here the OS allocates the resources to a process for a fixed amount of time.
During resource allocation, the process switches from running state to ready state or from
waiting state to ready state. This switching occurs as the CPU may give priority to other
processes and replace the process with higher priority with the running process.
The Operating System maintains the following important process scheduling queues −
Job queue − This queue keeps all the processes in the system.
Ready queue − This queue keeps a set of all processes residing in main memory, ready and
waiting to execute. A new process is always put in this queue.
Device queues − The processes which are blocked due to unavailability of an I/O device
constitute this queue.