Chapter 3
Chapter 3
Chapter 3
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.
6. User Programs:
●
This is the highest layer in the layered OS.
●
This layer deals with many user programs and applications that run in the OS such as word
processors, games, browser etc.
Advantages of layered structure
1. Modularity: this design promotes modularity as each layer performs only the
tasks it is scheduled to perform.
2. Easy debugging: Suppose an error occurs in the CPU scheduling layer, the
developer can only search that particular layer to debug.
3. Easy update: A modification made in a particular layer will not affect the
other layers.
4. No direct access to hardware: A user can use the services of hardware but
cannot directly modify or access it.
5. Abstraction: Every layer is concerned with its functions. So the functions and
implementation of the other layers are hidden to it.
Disadvantages of Layered Structure
1. Complex and careful implementation: as a layer can access the
services of the layers below it, so the arrangement of the layers must
be done carefully.
2. Slower in execution: if a layer wants to interact with another layer, it
requests to travel through all the layers present between the two
interacting layers. Thus it increases response time.
3. Functionalities: It is not always possible to divide the functionalities.
Many time they are interrelated and cannot be separated.
4. Communication: No communication between non- adjacent layers.
3.4 Protection in OS
●
Protection is important in a multi user environment when multiple
users use computer resources such as CPU, memory etc.
●
It is the OS’s responsibility to offer a mechanism that protects
each process from other processes.
●
In a multi user environment, all assets that require protection are
classified as objects and those that wish to access these objects
are referred to as subjects.
●
The OS grants different “access right” to different subjects.
Need of protection in OS
●
There may be security risks like unauthorized
reading, writing, modification or preventing the
system from working effectively for unauthorized
users.
●
It helps to ensure data security, process security
and program security against unauthorized user
access or program access.
3.5 Kernel
●
A kernel is the control module of an OS.
●
It is one which loads first and remains in the main memory.
●
Since kernel stays in memory, it must be kept as small as possible.
●
The OS kernel comprises of I/O drivers, CPU scheduler, pager, swapper etc.
●
In an operating system, the kernel is the core component that acts as a bridge between
the hardware and software.
●
It is responsible for managing system resources, providing essential services, and
facilitating communication between different parts of the operating system and hardware
devices.
●
The kernel handles tasks such as process management, memory management, device
drivers, and input/output operations.
●
It plays a crucial role in ensuring the stability, security, and proper functioning of the
operating system.
Some main functions of kernel are as follows:
●
It provides a mechanism for creation and deletion of processes.
●
It provides processor scheduling, memory management I/O management.
●
It provides mechanism for synchronization of processes.
●
It provides mechanism for interprocess communication.
4. All operating system services are Only IPC and low level device
included in kernel. management services are included in
kernel.
5. No message passing and no It requires message passing and
context switching is required context switching.
while the kernel is performing a
job.
6 Failure of a single component in a Failure of one component does not
monolithic kernel results in a system affect the working of micro kernel.
failure.
7 It is difficult to extend a monolithic It is simple to extend micro kernel.
kernel.
8 Eg: UNIX, LINUX kernel Eg: Kernel if MAC OS, windows NT.
3.6 Process and Threads
3.6.1 Process
●
A process is an activity of some kind.
●
It has a program code,input, output and a state.
●
We define the process as an instance of a program in execution.
●
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.
●
When you launch a web browser, it creates a new process. This process represents the
running instance of the web browser application. It has its own memory space, system
resources, and execution context. The process manages tasks such as rendering web
pages, handling user input, and managing network connections. Each time you open a new
instance of the web browser, a new process is created to handle that instance separately.
Process states/ Process life cycle
●
When a process executes, it passes through different states.
●
This stages may differ in different OS.
●
The life cycle of a process can be divided into several states, each with its own characteristics to
describe the process
●
Each process may be in one of the following states:
a. New: the process has been created but not yet admitted to the pool of executable processes.
b. Ready: the process is ready for execution and is waiting to be allocated to a processor. All
ready processes are kept in a queue and they keep waiting for CPU time to be allocated by the
OS in order to run.
c. Running: A process is now executing i.e. using the CPU. The instructions within a process are
executing.
d. Waiting: process moves into the waiting state if it needs to wait for a resource, such as waiting
for a file to become available.
e. Terminated: once the process finishes its execution, or it is terminated by the OS , it is moved
to the terminated state where it waits to be removed from main memory.
3.6.2 Threads
●
A thread is a unit of execution within a process.
●
A thread is similar to a sequential program like a thread also has a beginning, an
end , a sequence etc. but a thread itself is not a program and it cannot run on its
own. So it runs within a program.
●
A thread is a single sequential flow of control within a program.
●
A thread is also known as a light weight process. This is called so because it runs
within a program thus it makes use of the resources that were actually allocated to
the process(or program).
●
A thread also has its life cycle. They also share processor. A thread executes
sequentially within a process.
●
There can be more than one thread inside a process. Each thread of the same
process makes use of a separate PC and a stack of activation records and control
blocks.
●
The process can be split down into so many threads. For example, in a browser
many tabs can be viewed as threads.
Need of threads
●
It takes less time to create a new thread in an existing process
than to create a new process.
●
Threads can share a common data.
●
Context switching is faster when working with threads.
●
It takes less time to terminate a thread than a process.
Extra point:
Processes: Imagine you have a computer running a word processor, a web browser, and a
media player simultaneously. Each of these applications is a separate process. They have their
own memory space and resources, and they run independently of each other. If one process
crashes, it won't affect the others.
Threads: Within each process, there can be multiple threads. Let's take the example of a web
browser. When you open a new tab and load a webpage, the browser may create a separate
thread to handle that task. This thread runs concurrently with the main thread of the browser,
allowing you to interact with other tabs or perform other actions while the webpage is being
loaded. Threads share the same memory space and resources within a process and can
communicate with each other easily.
Extra point:
Processes: Imagine you have a computer running a word processor, a web browser, and a
media player simultaneously. Each of these applications is a separate process. They have their
own memory space and resources, and they run independently of each other. If one process
crashes, it won't affect the others.
Threads: Within each process, there can be multiple threads. Let's take the example of a web
browser. When you open a new tab and load a webpage, the browser may create a separate
thread to handle that task. This thread runs concurrently with the main thread of the browser,
allowing you to interact with other tabs or perform other actions while the webpage is being
loaded. Threads share the same memory space and resources within a process and can
communicate with each other easily.
S.N. Process Threads
1. Processes cannot share the same Threads can share memory and files.
memory.
2. Process creation is time consuming. Thread creation is not time consuming.