227 122 Rtos-Module1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

ECT426: REAL TIME

OPERATING SYSTEM
MODULE 1

1
PREPARED BY

DIVYA HARIKUMAR

ASST. PROFESSOR

DEPT. OF ECE, SCTCE


2 CONTENTS

 Introduction to Operating system- Types, Objective and functions


 Kernel - Importance and functions
 Process - States, Process Control Block, Operations on processes
3 OPERATING SYSTEM

 An Operating system forms the core of any computer device.


 The functioning and processing of a computer system can come to hold
without an operating system.
 An operating system is a program that manages a computer’s hardware.
 It provides a basis for application programs.
 An Operating System is the interface between the computer hardware and
the end-user.
 Processing of data, running applications, file management and handling
the memory is all managed by the computer OS.
4 OPERATING SYSTEM

 Windows, Mac, Android etc. are examples of Operating systems which are
generally used nowadays.
 All modern computing devices including Laptops, Tablet, mobile phones,
etc. comprise an Operating System which helps in the smooth working of
the device.
 Personal computer (PC) operating systems support complex games,
business applications. Etc.
5 COMPONENTS OF A COMPUTER SYSTEM
6 COMPONENTS OF A COMPUTER SYSTEM

 A computer system can be divided roughly into four components:


• The hardware,
• The operating system,
• the application programs,
• and the users
 The hardware—the central processing unit (CPU), the memory, and the
input/output (I/O) devices—provides the basic computing resources for the
system.
 The application programs—such as word processors, spreadsheets,
compilers, and Web browsers—define the ways in which these resources
are used to solve user’s computing problems.
 The operating system controls the hardware and coordinates its use among
the various application programs for the various users
7 Types of Operating System

Widely used operating systems are as follows:

1. Batch Operating System


2. Time-Sharing Operating Systems
3. Distributed Operating System
4. Network Operating System
5. Real-Time Operating System
6. Embedded Operating System
7. Mobile Operating System
8 Batch Operating System
9 Batch Operating System

1. Batch Operating System


 There is no direct communication between the computer and the OS.
 There is an intermediate, the Operator, which needs to distribute the work
into batches and sort similar jobs.
 Multiple users can use it.
 Can easily manage a large amount of work.
 Examples of Batch based Operating System: Payroll System, Bank
Statements, etc
 Advantages of Batch Operating System:
10 • Processors of the batch systems know how long the job would be when it is
in queue
• Multiple users can share the batch systems
• The idle time for the batch system is very less
• It is easy to manage large work repeatedly in batch systems

 Disadvantages of Batch Operating System:

• 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
11 Real-Time Operating System
12 Real-Time Operating System
 These types of OSs serve real-time systems.
 It has a data processing system.
 The processing time is very small between the user’s command and the output. This time
interval is called response time.
 Used in fields where the response needs to be quick and rapid.
 Real-time systems are used when there are time requirements that are very
strict like missile systems, air traffic control systems, robots, etc.
 Examples of Real-Time Operating Systems are:
Scientific experiments, medical imaging systems, industrial control systems,
weapon systems, robots, air traffic control systems, etc.
 Two types of Real-Time Operating Systems are:
 Hard Real-Time Systems
 Soft Real-Time Systems
13 Real-Time Operating System

 Hard RTOS
 These OSs are meant for applications where time constraints are very
strict and even the shortest possible delay is not acceptable.
 These systems are built for saving life like automatic parachutes or
airbags which are required to be readily available in case of any
accident.
 Virtual memory is rarely found in these systems.
 Soft RTOS
 These OSs are for applications where for time-constraint is less strict.
 Advantages of RTOS:
14  Maximum Consumption: Maximum utilization of devices and system, thus
more output from all the resources
 Focus on Application: Focus on running applications and less importance to
applications which are in the queue.
 Real-time operating system in the embedded system: Since the size of programs
are small, RTOS can also be used in embedded systems like in transport and
others.
 Error Free: These types of systems are error-free.
 Memory Allocation: Memory allocation is best managed in these types of
systems.
 Task Shifting: The time assigned for shifting tasks in these systems are very
less.
For example, in older systems, it takes about 10 microseconds in shifting one task
to another, and in the latest systems, it takes 3 microseconds.
 Disadvantages of RTOS:
15  Limited Tasks: Very few tasks run at the same time and their concentration
is limited to 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.
 Device driver and interrupt signals: It needs specific device drivers and
interrupts signals to respond earliest to interrupts.
 Thread Priority: It is not good to set thread priority as these systems are very
less prone to switching tasks.
16 Time-Sharing Operating Systems
17 Time-Sharing Operating Systems

 Multiple people at various terminals can use a program at the same time.
 The main motive is to minimize the response time.
 Each task is given some time to execute so that all the tasks work smoothly.
 Each user gets the time of CPU as they use a single system.
 These systems are also known as Multitasking Systems.
 The task can be from a single user or different users also.
 The time that each task gets to execute is called quantum.
 After this time interval is over OS switches over to the next task.
 Examples of Time-Sharing OSs are: Multics, Unix,
 Advantages of Time-Sharing OS:
18
 Each task gets an equal opportunity
 Fewer chances of duplication of software
 CPU idle time can be reduced

 Disadvantages of Time-Sharing OS:


 Reliability problem
 One must have to take care of the security and integrity of user programs and data.
 Data communication problem
19 Distributed Operating System
20 Distributed Operating System

 When two or more systems are connected to each other and one can open
files which are not present in their system but in other devices connected in
the network. i.e., remote access is enabled within the devices connected in
that network.
 Its usage has now increased over the years.
 They use multiple central processors to serve real-time applications.
 Failure of one system does not affect the other systems connected in the
network.
 These system’s processors differ in size and function.
 Examples of Distributed Operating System are- LOCUS
21 Distributed Operating System

 Advantages of Distributed Operating System:


 Failure of one will not affect the other network communication, as all systems
are independent from each other.
 Electronic mail increases the data exchange speed.
 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.
22  Disadvantages of Distributed Operating System:
 Failure of the main network will stop the entire communication.
 To establish distributed systems the language which is used are not well
defined yet.
 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
23 Network Operating System
24 Network Operating System

 They have one main server which is connected to other client servers.
 All the management of files, processing of data, access to sharing files, etc. are
performed over this small network.
 It is also a secure operating system for working with multiple users.
 One 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
 Examples of Network Operating System are: Microsoft Windows Server 2003,
Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and
BSD, etc.
25 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.

Disadvantages of Network Operating System:

• Servers are costly.


• User has to depend on a central location for most operations.
• Maintenance and updates are required regularly.
Embedded Operating System.
26  These special Operating systems are built into larger systems.
 They generally are limited to single specific functions like an ATM.
Mobile Operating System
 With the advancement in the field of technology, smartphones now are
released with an Operating system.
 They are designed in a manner that they can help a small device work
efficiently.
27 OBJECTIVES OF OPERATING SYSTEM

 Convenience: An OS makes a computer more convenient to use.


 Efficiency: An OS allows the computer system resources to be used in an
efficient manner.
 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 without interfering with service
28 FUNCTIONS OF AN OPERATING SYSTEM

1. Memory Management
2. Processor Management
3. Device Management
4. File Management
5. Security
6. Control over system performance
7. Job accounting
8. Error detection & Response
9. Booting the computer
10.Coordination between other software and users
29
30
31
32

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


33
34
35
36
37 Kernel

 The kernel is the essential foundation of a computer's operating system.


 It is the core that provides basic services for all other parts of the OS.
 It is the main layer between the OS and underlying computer hardware, and it
helps with tasks such as process and memory management, file systems, device
control and networking.
 During normal system startup, a computer's basic input/output system, completes
a hardware bootstrap or initialization.
 It then runs a bootloader which loads the kernel from a storage device -- such as
a hard drive -- into a protected memory space.
 Kernel is central component of an operating system that manages operations of
computer and hardware. It basically manages operations of memory and CPU
time.
 It is core component of an operating system.
38  Kernel acts as a bridge between applications and data processing
performed at hardware level using inter-process communication and
system calls.
 Kernel loads first into memory when an operating system is loaded and
remains into memory until operating system is shut down again.
 Kernel has a process table that keeps track of all active processes
• Process table contains a per process region table whose entry points to
entries in region table.
 Kernel loads an executable file into memory during ‘exec’ system call’.
 It decides which process should be allocated to processor to execute and
which process should be kept in main memory to execute.
 The major aim of kernel is to manage communication between software i.e.
user-level applications and hardware i.e., CPU and disk memory

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


 Once the kernel is loaded into computer memory, the BIOS transfers control
to the kernel. It then loads other OS components to complete the system
39 startup and make control available to users through a desktop or other user
interface.
 If the kernel is damaged or cannot load successfully, the computer will be
unable to start completely -- if at all. This will require service to correct
hardware damage or restore the operating system kernel to a working
version.
40

What is the purpose of the kernel?


An OS kernel performs three primary jobs.
 It provides the interfaces needed for users and applications to interact with
the computer.
 It launches and manages applications.
 It manages the underlying system hardware devices.
41
 Accomplishing the three kernel functions involves a range of
computer tasks, including the following:
 Loading and managing less-critical OS components, such as device
drivers;
 Organizing and managing threads and the various processes
spawned by running applications;
 Scheduling which applications can access and use the kernel, and
supervising that use when the scheduled time occurs;
 Deciding which non-protected user memory space each application
process uses;
 Handling conflicts and errors in memory allocation and management;
 Scheduling and management are central to the kernel's operation.
42
 Computer hardware can only do one thing at a time.
 However, a computer's OS components and applications has dozens
and even hundreds of processes that the computer must host. It's
impossible for all of those processes to use the computer's hardware --
such as a memory address or CPU instruction pipeline -- at the same
time.
 The kernel is the central manager of these processes. It knows which
hardware resources are available and which processes need them. It
then allocates time for each process to use those resources.
 The kernel is critical to a computer's operation, and it requires careful
protection within the system's memory.
 The kernel space it loads into is a protected area of memory. That
protected memory space ensures other applications and data don't
overwrite or impair the kernel, causing performance problems,
instability or other negative consequences. Instead, applications are
loaded and executed in a generally available user memory space.
 A kernel is often contrasted with a shell, which is the outermost part of
an OS that interacts with user commands.

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


43  Managing and optimizing hardware resources and dependencies,
such as CPU and cache use, file system operation and network
transport mechanisms;
 Managing and accessing input/output devices such as keyboards,
mouse, disk drives, USB ports, network adapters and displays; and
 Handling device and application system calls using various
mechanisms such as hardware interrupts or device drivers.
44 Device drivers

 A key part of kernel operation is communication with hardware devices


inside and outside of the physical computer.
 It is impractical to write an OS capable of interacting with every possible
device in existence.
 Instead, kernels rely on the ability of device drivers to add kernel support for
specialized devices, such as printers and graphics adapters.
 When an OS is installed on a computer, the installation adds device drivers
for any specific devices detected within the computer. This helps tailor the
OS installation to the specific system with just enough components to
support the devices present. When a new or better device replaces an
existing device, the device driver is updated or replaced.

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


45 Types of Kernel

 Kernels fall into three architectures: monolithic, microkernel and hybrid.


 The main difference between these types is the number of address
spaces they support.
 A microkernel delegates user processes and services and kernel services in
different address spaces.
 A monolithic kernel implements services in the same address space.
 A hybrid kernel, such as the Microsoft Windows NT and Apple XNU kernels,
attempts to combine the behaviors and benefits of microkernel and
monolithic kernel architectures.
 Admins get the flexibility of more source code with microkernels or they get
increased security without customization options with the monolithic kernel.
46 Types of Kernel

 Monolithic Kernel:
 Monolithic kernels are the simplest and most common type of
Kernel.
 They include the core functionality of the operating system and
support all devices connected to it.
 In this, the user and kernel services are implemented in the same
memory space. Due to this, the size of the kernel increases,
which in turn increases the size of the operating system.
 The main benefit is that the process execution is faster as there is
no separate memory space for the user and Kernel.
47 Monolithic Kernel

Example:
Unix, Linux, Open VMS, XTS-400 etc.

Advantage:
It has good performance.
Disadvantage:
It has dependencies between system component and lines of code in millions.

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


48 Types of Kernel

 Microkernel:
 Microkernels are a newer development and, as such, are not as
common as monolithic kernels.
 They include only the essential services and devices required for
the system to function.
 This results in a smaller kernel that is faster and uses less memory.
 Here, the user and kernel services are implemented in two
different spaces. It has separate User Space and Kernel Space.
 This reduces the size of the Kernel and results in reducing the size
of the operating system.
49 Microkernel

 Example :
Mach, L4, AmigaOS, Minix, K42 etc.
 Advantages:
It is more stable.
 Disadvantage :
There are lots of system calls and context switches.
50 Types of Kernel

 Hybrid Kernel:
 Hybrid kernels combine monolithic and microkernels.
 They include more services than microkernels but less than
monolithic kernels.
 This allows them to offer some of the benefits of both kernels.
 It borrows speed from the monolithic kernels and modularity
from microkernels.
51 Hybrid Kernel:

 Example :

Windows NT, Netware, BeOS etc.

Advantage :
It combines both monolithic kernel and microkernel.
Disadvantage :
It is still similar to monolithic kernel.
52 Types of Kernel
 Nano Kernel:
 Nano kernels are the smallest type of Kernel, consisting of only a
few thousand lines of code.
 They are used primarily in embedded systems or devices with
limited resources.
 Example :

EROS

Advantage :
It offers hardware abstractions without system services.
Disadvantage :
It is quite same as Micro kernel hence it is less used
53 Types of Kernel

Exo Kernel:
 This Kernel has separate resource protection and management.
 It is suitable for use when performing application-specific
customization.
 Exo kernels are designed for use in mobile devices.
 They are a variation of microkernels that include additional features
specifically for mobile devices, such as power management and
support for multiple processors.
54 Exo Kernel

Example :

Nemesis, ExOS etc.

Advantage :
It has fewest hardware abstractions.

Disadvantage :
There is more work for application developers

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


Advantages of the Kernel
55  It is responsible for managing the system’s resources, including memory,
processors, and devices.
 Provides essential services to users and applications, such as security,
multitasking, and communications.
 It handles essential tasks such as suspending or terminating processes when
needed.
 It improves performance, better security, and increased stability.
Disadvantages of the Kernel
 The developer should need to consider the particular requirements of the
device. But, not all developers are familiar with the specific hardware
requirements of each device.
 The Kernel can be vulnerable to attacks. If an attacker can exploit a
vulnerability in the Kernel, they could gain access to your system and
damage or steal your data.
56 User-mode and kernel mode
User Mode
 When an application like MS word handling a text editor runs on the
operating system, the system is in user mode.
 The mode bit is 1 in that case. The mode bit will change from 1 to 0 if it
switches to kernel mode. The user mode to kernel mode is switched when
there is a need to access any device or any interrupt/system call occurs.
Kernel-mode
 When the system boots, the system starts with kernel mode. And the
applications are executed in user mode. The switch can happen from user
mode to kernel mode when
 Interrupt occurs
 Need to access privileged instruction
 Need to access any device
 The mode bit is changed from 0 to 1 in case of the system switch back to
user mode.
PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE
57 Process

 A process is a dynamic instance of a computer program that is


being sequentially executed by a computer system that has the
ability to run several computer programs concurrently.
 A computer program itself is just a passive collection of instructions,
while a process is the actual execution of those instructions.
 Several processes may be associated with the same program; for
example, opening up several windows of the same program
typically means more than one process is being executed.
58  Several Definition for Process include:

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


59 PCB

• Process operations can be easily controlled with the help of PCB(Process


Control Block).
• It can be considered as the brain of the process, which contains all the crucial
information related to processing like process id, priority, state, CPU registers,
etc.
• A Process Control Block is a data structure in the operating system kernel
containing the information needed to manage a particular process.
• A PCB is created in the kernel whenever a new process is started.
• The OS maintains a queue of PCBs, one for each process running in the
system.
60

Control Block(PCB)
61 PCB

• Since the PCB contains the critical information for the process, it must be
kept in an area of memory protected from normal user access.
• In some operating systems the PCB is placed in the beginning of the kernel
stack of the process since that is a convenient protected location.
• The PCB is maintained for a process throughout its lifetime, and is deleted
once the process terminates.
• PCB has sufficient information so that it is possible to interrupt a running
process and later resume its operation as if the interruption had not
occurred.
62 Process States

PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE


63 Process States
 The process, from its creation to completion, passes through various
states. The minimum number of states is five.
 The names of the states are not standardized although the process may
be in one of the following states during execution.
1. New
 A program which is going to be picked up by the OS into the main
memory is called a new process.
2. Ready
 Whenever a process is created, it directly enters in the ready state, in
which, it waits for the CPU to be assigned. The OS picks the new
processes from the secondary memory and put all of them in the main
memory.
 The processes which are ready for the execution and reside in the main
memory are called ready state processes. There can be many
processes present in the ready state.
3. Running
64
 One of the processes from the ready state will be chosen by the OS
depending upon the scheduling algorithm.
 Hence, if we have only one CPU in our system, the number of running
processes for a particular time will always be one. If we have n processors
in the system then we can have n processes running simultaneously.
4. Block or wait
 From the Running state, a process can make the transition to the block or
wait state depending upon the scheduling algorithm or the intrinsic
behavior of the process.
 When a process waits for a certain resource to be assigned or for the input
from the user then the OS move this process to the block or wait state and
assigns the CPU to the other processes.
5. Completion or termination
 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.
PREPARED BY DIVYA HARIKUMAR_ASST PROFESSOR_DEPT OF ECE_SCTCE
6. Suspend ready
65
 A process in the ready state, which is moved to secondary memory from
the main memory due to lack of the resources (mainly primary memory) is
called in the suspend ready state.
 If the main memory is full and a higher priority process comes for the
execution then the OS have to make the room for the process in the main
memory by throwing the lower priority process out into the secondary
memory. The suspend ready processes remain in the secondary memory
until the main memory gets available.
7. Suspend wait
 Instead of removing the process from the ready queue, it's better to remove
the blocked process which is waiting for some resources in the main
memory. Since it is already waiting for some resource to get available
hence it is better if it waits in the secondary memory and make room for the
higher priority process. These processes complete their execution once the
main memory gets available and their wait is finished.
66 Operations on the Process
1. 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.
2. 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.
3. 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.
4. Deletion/killing
 Once the purpose of the process gets over then the OS will kill the process.
The
PREPARED Context
BY DIVYA of the
HARIKUMAR_ASST process
PROFESSOR_DEPT (PCB) will be deleted and the process gets
OF ECE_SCTCE
terminated by the Operating system.
67 MODULE 1 QUESTIONS

1. List the functions of operating systems.


2. Describe the importance of Kernel in operating system functions.
3. Explain monolithic and layered architecture of operating systems.
4. Draw the process state diagram and explain.
5. Differentiate microkernel and exokernel structures of operating systems.
6. Explain the different operations on processes.
7. Explain the functions of operating system as Resource Manager.
8. Describe the structure of a Process Control Block
9. Explain the monolithic and microkernel architectures of OS kernel.
10. Draw the process state diagram and explain the different states.

You might also like