Os Unit1
Os Unit1
AY: 2023-2024
OPERATING SYSTEMS
UNIT - 1
Disadvantages:
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
Examples of Batch based Operating System: Payroll System, Bank Statements, etc.
Multiprogramming Operating System
To overcome the problem of under utilization of CPU and main memory, the multi-programming was
introduced. The multi-programming is interleaved execution of multiple jobs by the same computer.
In Multiprogramming system, CPU will never be idle and keeps on processing. In this the operating system
picks up and begins to execute one of the jobs from memory. Once this job needs an I/O operation operating
system switches to another job (CPU and OS always busy).
Multiprogramming Operating System
An OS does the following activities related to multiprogramming.
The operating system keeps several jobs in memory at a time.
This set of jobs is a subset of the jobs kept in the job pool.
The operating system picks and begins to execute one of the jobs in the memory.
Multiprogramming operating systems monitor the state of all active programs and system resources using
memory management programs to ensures that the CPU is never idle, unless there are no jobs to process.
Advantages
High and efficient CPU utilization.
User feels that many programs are allotted CPU almost simultaneously.
Disadvantages
CPU scheduling is required.
To accommodate many jobs in memory, memory management is required.
Time-Sharing Operating System
In this operating system allows multiple users to share the system simultaneously.
Each user is provided a time slice and the processor switches rapidly among the users according to it.
More than one processes are being executed at a particular time with the help of the time-sharing concept.
So, in the time-sharing environment, we decide a time that is called time quantum and when the process
starts its execution then the execution continues for only that amount of time and after that, other processes
will be given chance for that amount of time only. In the next cycle, the first process will again come for its
execution and it will be executed for that time quantum only and again next process will come. This process
will continue.
Time-Sharing Operating System
Advantages:
Since equal time quantum is given to each process, so each process gets equal opportunity to execute.
CPU will be busy in most of the cases.
Provides the advantage of quick response.
Avoids duplication of software.
Reduces CPU idle time.
Disadvantages:
Reliability problem
One must have to take care of the security and integrity of user programs and data
Data communication problem
Disadvantages of RTOS:
Limited Tasks: Very few tasks run at the same time and their concentration is very less on few applications to avoid
errors.
Use heavy system resources: Sometimes the system resources are not so good and they are expensive as well.
Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.
Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging systems, industrial control
systems, weapon systems, robots, air traffic control systems, etc.
Network Operating System
These systems run on a server and provide the capability to manage data, users, groups, security,
applications, and other networking functions.
These types of operating systems allow shared access of files, printers, security, applications, and other
networking functions over a small private network.
One more important aspect of Network Operating Systems is that all the users are well aware of the
underlying configuration, of all other users within the network, their individual connections, etc. and that’s
why these computers are popularly known as tightly coupled systems. (with different operating systems)
Network Operating System
Advantages of Network Operating System:
Highly stable centralized servers
Security concerns are handled through servers
New technologies and hardware up-gradation are easily integrated into the system
Server access is possible remotely from different locations and types of systems
Examples of Network Operating System are: Microsoft Windows Server 2003, Microsoft Windows Server
2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD, etc.
Mobile Operating System
A mobile operating system (mobile OS) is an OS built exclusively for a mobile device, such as a
smartphone, personal digital assistant (PDA), tablet or other embedded mobile OS.
A mobile OS is responsible for identifying and defining mobile device features and functions, including
keypads, application synchronization, email, thumbwheel and text messaging.
A mobile OS is similar to a standard OS (like Windows, Linux, and Mac) but is relatively simple and light
and primarily manages the wireless variations of local and broadband connections, mobile multimedia and
various input methods.
Mobile Operating System
It is an Operating System for mobiles, tablets, 2-in-1 PC’s (that can be convert to laptop mode or detach
and work as tablet mode.
Mobile OS have majority use since (2017)
Previously (1993)---Embedded systems
1993-1999---Pen Point OS (APRIL 1993)
APPLE LAUNCHES (NEWTON OS)
1994---MARCH---Magic Cap OS
AUG---first smart phone(IBM) with touch screen
1996----march ---palm OS
AUG---Nokia---(PEN/GEOS)
2019------jan /windows 10----IOS/android
September—Apple-ios13-----Iphone11
Smart Watch OS6---ipad---7th Gen
And soon………..
Distributed Operating Systems
These types of the operating system is a recent advancement in the world of computer technology and are
being widely accepted all over the world.
Various autonomous interconnected computers communicate with each other using a shared communication
network.
Independent systems possess their own memory unit and CPU. These are referred to as loosely coupled
systems or distributed systems. These system’s processors differ in size and function.
The major benefit of working with these types of the operating system is that it is always possible that one
user can access the files or software which are not actually present on his system but some other system
connected within this network i.e., remote access is enabled within the devices connected in that network.
Distributed Operating Systems
Advantages:
Failure of one system will not affect the other network communication, as all systems are independent from
each other
Electronic mail increases the data exchange speed (sending the data through Email)
Since resources are being shared, computation is highly fast and durable
Load on host computer reduces
These systems are easily scalable as many systems can be easily added to the network
Delay in data processing reduces
Disadvantages:
Failure of the main network will stop the entire communication
These types of systems are not readily available as they are very expensive. Not only that the underlying
software is highly complex and not understood well yet
Example: LOCUS(LOCUS is a distributed operating system which supports transparent access to data
through a network wide file system, permits automatic replication of storage, supports transparent distributed
process execution) , etc.
OS System Components
•An operating system is a large and complex system that can only be created by partitioning into small parts.
These pieces should be a well-defined part of the system, carefully defining inputs, outputs, and functions.
•The components of an operating system play a key role to make a variety of computer system parts work
together. There are the following components of an operating system, such as:
Process Management
File Management
Network Management
Main Memory Management
Secondary Storage Management
I/O Device Management
Security Management
Command Interpreter System
OS System Components
Process Management
•The process management component is a procedure for managing many processes running simultaneously
on the operating system. Every running software application program has one or more processes associated
with them.
•For example, when you use a search engine like Chrome, there is a process running for that browser
program.
•Process management keeps processes running efficiently. It also uses memory allocated to them and shutting
them down when needed.
•The execution of a process must be sequential so, at least one instruction should be executed on behalf of the
process.
Functions of process management
Process creation and deletion.
Suspension and resumption.
Synchronization process
Communication process
OS System Components
2. File Management
A file is a set of related information defined by its creator. It commonly represents programs (both source and
object forms) and data. Data files can be alphabetic, numeric, or alphanumeric.
Function of file management
File and directory creation and deletion.
For manipulating files and directories.
Mapping files onto secondary storage.
Backup files on stable storage media.
OS System Components
3. Network Management
•Network management is the process of administering and managing computer networks.
•It includes performance management, provisioning of networks, fault analysis, and maintaining the quality
of service.
User Interface:
GUI: graphical user interface : windows environment (ex: window interface by using the pointer
device(mouse) we will operate the system and keyboard to enter text etc…
Batch Interface: all commands and directives are entered in to files (these files are executed to control the
commands or access the system
CLI: Command Line Interface: user enters commands to access system (unix / linux commands in
terminal)
OS Services
I/O Management:
A running program may require I/O, which may involve a file or an I/O device.
For efficiency and protection , users cannot control I/O devices directly, therefore, the operating system
must provide a means to do I/O.(ex: user wants to take printouts OS should provide connection between file
and printer device)
File system Management:
The file system is of particular interest (how to manage files)
Obviously programs need to read and write files and directories.
They also need to create and delete them by name, search for given file etc…
Some operating systems include permissions management to allow or deny access to files or directories
based on file ownership(personal file).
Communications:
There are many circumstances in which one process needs to exchange information with another processes
This communication may be on the same computer or on different computers(tied into a network) via shared
memory or message passing (distributed/network OS) which is done by operating system
OS Services
Error Detection:
The OS needs to be detecting and correcting errors constantly.
Errors may occur in the
CPU and Memory hardware(such as memory error or power failure)
I/O devices(such as parity error on disk, a connection failure on network, or lack of paper in the printer)
A parity error is an error that results from irregular changes to data.
User program(such as arithmetic overflow, an attempt to access an illegal memory location etc..
In the above cases the OS should take appropriate action to control the errors. In worst cases the system
itself will hang / struck. So we need to restart the computer.
Accounting:
we want to keep track of which users use how much and what kind of computer resources.
This record keeping may be used for accounting or for usage statistics (may be valuable tool for researchers
who wish to reconfigure the system to improve computing services)
OS Services
Resource allocation:
when multiple jobs or users running at same time then resources must be allocated to each of them
The OS manages many different types of resources
CPU cycles(scheduling algorithms), main memory, file storage (special allocation code)
I/O devices(request and release codes)(request for printer, scanner, mouse, keyboard etc..)
File Protection and Security:
Protection:
When several separate processes execute concurrently , it should not be possible for one process to
interfere with another (one process execution should not interrupt another process)
Each process should access the system resources in control(resources should not be wasted unnecessarily).
Security:
Security for system from outsiders is also important
So each user has to authenticate himself/herself to the system
By using password to (Access the system resources).
System Calls
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.
The interface between a process and an operating system is provided by system calls
In general, system calls are available as assembly language instructions.
System calls are usually made when a process in user mode requires access to a resource. Then it requests
the kernel to provide the resource via a system call.
When a System Calls requires
In general, system calls are required in the following situations −
If a file system requires the creation or deletion of files. Reading and writing from files also require a
system call.
Creation and management of new processes.
Network connections also require system calls. This includes sending and receiving packets.
Access to a hardware devices such as a printer, scanner etc. requires a system call.
Types of System Calls
There are mainly five types of system calls. These are explained in detail as follows
1. Process Control
These system calls deal with processes such as create, end, abort, terminate, allocate and free memory, etc.
Functions:
End and Abort
Load and Execute
Create Process and Terminate Process
Wait and Signed Event
Allocate and free memory
2. File Management
These system calls are responsible for file manipulation such as creating a file, reading a file, writing into a
file etc.
Functions:
Create a file
Delete file
Open and close file
Read, write, and reposition
Get and set file attributes
Types of System Calls
3. Device Management: These system calls are responsible for device manipulation such as reading from
device buffers, writing into device buffers etc.
Functions:
Request and release device
Logically attach/ detach devices
Get and Set device attributes
4. Information Maintenance: These system calls handle information and its transfer between the operating
system and the user program.
Functions:
Get or set time and date
Get process and device attributes
5. Communication: These system calls are useful for inter process communication. They also deal with
creating and deleting a communication connection.
Functions:
Create, delete communications connections
Send, receive message
Help OS to transfer status information
Types of System Calls
6. Protection and Security:
Protection:
When several separate processes execute concurrently , it should not be possible for one process to
interfere with another (one process execution should not interrupt another process)
Each process should access the system resources in control(resources should not be wasted unnecessarily).
Security:
Security for system from outsiders is also important
So each user has to authenticate himself/herself to the system
By using password to (Access the system resources).
Examples of System Calls
Process Definition
A process is a program in execution which then forms the basis of all
computation.
Process executes instructions sequentially, one at a time, until completion
A process is defined as an entity which represents the basic unit of work to be
implemented in the system
Program is passive entity stored on disk (executable file), process is active
program becomes process when executable file loaded into memory
Process needs CPU, memory, I/O, files, Initialization data resources to
accomplish its task
Process in 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.
Current activity including program counter, processor registers
Process Relationship
A process may create several number of processes (via A create process system call) during the course of
execution.
The creating process is called a parent process, and the new processes are called the children of that
process.
Each of these new processes may intern create other processes forming a tree of processes.
Parent process create children processes, which, in turn create other processes, forming a tree of processes.
When a process creates a new process, two possibilities exists in terms of execution.
parent
The parent continues to execute concurrently with its children
The parent waits until some (or) all of its children have terminated
child child
child child child
Operations on processes:
Process Creation:
When a process creates a new process, two possibilities exists in terms of execution.
The parent continues to execute concurrently with its children
The parent waits until some (or) all of its children have terminated
Address space
Child duplicate of parent. (child uses same resources which the parent is using)
Child has a program loaded into it.
Child process has a new program loaded into it which is different from parent program(then child will request for
other resources which are different from parent resources).
Generally process identified and managed via Process id(PID)
Possible resource sharing:
Parent and children share all resources.
Children share subset of parent’s resources.(some services of parent)
Some times the resources may be different for parent and child.
Possible execution:
Parent and children execute concurrently.
Parent waits until all the children gets terminated.
fork() system call creates new process
exec() system call used after a fork() to replace the process memory space with a new program
Process Termination:
Process executes last statement and then asks the operating system to delete it using the exit() system call.
Returns status data from child to parent (via wait())
Process resources are de-allocated by operating system
Parent may terminate the execution of children processes using the abort() system call. Some reasons for
doing so:
Child has exceeded allocated resources
Task assigned to child is no longer required
The parent is exiting and the operating systems does not allow a child to continue if its parent terminates
Some operating systems do not allow child to exists if its parent has terminated. If a process terminates,
then all its children must also be terminated.
cascading termination. All children, grandchildren, etc. are terminated.
The termination is initiated by the operating system.
The parent process may wait for termination of a child process by using the wait()system call. The call
returns status information and the pid of the terminated process
pid = wait(&status);
If no parent waiting (did not invoke wait()), process is a zombie
If parent terminated without invoking wait , process is an orphan
Basic Operations on the Process
Creation
Once the process is created, it will be ready and come into the ready queue (main memory) and will be ready
for the execution.
Scheduling
Out of the many processes present in the ready queue, the Operating system chooses one process and start
executing it. Selecting the process which is to be executed next, is known as scheduling.
Execution
Once the process is scheduled for the execution, the processor starts executing it. Process may come to the
blocked or wait state during the execution then in that case the processor starts executing the other processes.
Deletion/killing
Once the purpose of the process gets over then the OS will kill the process. The Context of the process
(PCB) will be deleted and the process gets terminated by the Operating system.
Different states of a Process (Life Cycle of the Process)
As a process executes, it changes state
New
Ready
Running
Waiting or Blocked
Terminated or Completed
Process States (Life Cycle of the Process)
New: This is the state when the process is being created. It is the initial state in the process life cycle.
Ready: After the creation of a process, the process enters the ready state i.e. the process is loaded into the main
memory. The process here is ready to run and is waiting to get the CPU time for its execution. The process is waiting to
be assigned to a processor
Running: process is being executed i.e The process is chosen by CPU for execution and the instructions within the
process are executed by any one of the available CPU core.
Waiting or Blocked: The process is waiting for some event to occur i.e Whenever the process requests access to I/O or
needs input from the user or needs access to a critical region(the lock for which is already acquired) it enters the
blocked or wait state. The process continues to wait in the main memory and does not require CPU. Once the I/O
operation is completed the process goes to the ready state.
Terminated or Completed: When a process finishes its execution, it comes in the termination state. All the context of
the process (Process Control Block) will also be deleted the process will be terminated by the Operating system.
Other Process States:
Suspend ready – Process that was initially in the ready state but were swapped out of main memory(refer Virtual
Memory topic) and placed onto external storage by scheduler are said to be in suspend ready state. The process will
transition back to ready state whenever the process is again brought onto the main memory.
Suspend wait or suspend blocked – Similar to suspend ready but uses the process which was performing I/O
operation and lack of main memory caused them to move to secondary memory. When work is finished it may go to
suspend ready.
Process State Transitions
Process State Transitions
Process Control Block (PCB)
It is also called as Central repository(Store) for a process.
Information associated with each process (also called task control block)
process control stores many data items as follows that are needed for efficient
process management
Pointer: It contains the address of another process which is present in
the ready queue.
Process State: This specifies the process state i.e. new, ready, running,
waiting or terminated.
Process Number: This shows the number of the particular process.
Program Counter: This contains the address of the next instruction
that needs to be executed in the process.
Registers: This specifies the registers that are used by the process.
They may include accumulators, index registers, stack pointers, general
purpose registers etc.
List of Open Files: These are the different files that are associated with
the process
Process Control Block (PCB)
CPU Scheduling Information: The process priority, pointers to scheduling
queues etc. is the CPU scheduling information that is contained in the PCB.
This may also include any other scheduling parameters.
Memory Management Information: The memory management information
includes the page tables or the segment tables depending on the memory system
used. It also contains the value of the base registers, limit registers etc.
I/O Status Information: This information includes the list of I/O devices
used by the process, the list of files etc.
Accounting information: The time limits, account numbers, amount of CPU
used, process numbers etc. are all a part of the PCB accounting information.
Location of the Process Control Block: The process control block is kept in
a memory area that is protected from the normal user access. This is done
because it contains important process information. Some of the operating
systems place the PCB at the beginning of the kernel stack for the process as it
is a safe location.
Context Switching
A context switching is a process that involves switching of the CPU from one process or task to another.
In computing, a context switch is the process of storing the state of a process or thread, so that it can be
restored and resume execution at a later point. This allows multiple processes to share a single central
processing unit (CPU), and is an essential feature of a multitasking operating system.
Context Switching Steps
The steps involved in context switching are as follows −
Save the context of the process that is currently running on the CPU. Update the process control block
and other important fields.
Update the process control block of the selected process. This includes updating the process state to
running.
Update the memory management data structures as required.
Restore the context of the process that was previously running when it is loaded again on the processor.
This is done by loading the previous values of the process control block and registers.
Information to be stored for context switching in PCB is:-
1) Program counter 2) Scheduling information
3) Changed state 4) Accounting Information
5) Base and Limit register
CPU Switch From Process to Process
Context Switching
Example of Context Switching
Suppose that multiple processes are stored in a Process Control Block
(PCB).
One process is running state to execute its task with the use of CPUs.
As the process is running, another process arrives in the ready queue,
which has a high priority of completing its task using CPU.
Here we used context switching that switches the current process with
the new process requiring the CPU to finish its tasks.
While switching the process, a context switch saves the status of the old
process in registers.
When the process reloads into the CPU, it starts the execution of the
process when the new process stops the old process.
If we do not save the state of the process, we have to start its execution
at the initial level.
In this way, context switching helps the operating system to switch
between the processes, store or reload the process when it requires
executing its tasks.
Cooperating Processes
•Cooperating Processes are those processes that depend on other processes or processes.
•They work together to achieve a common task in an operating system.
•These processes interact with each other by sharing the resources such as CPU, memory, and I/O devices to
complete the task.