0% found this document useful (0 votes)
66 views

Operating Systems Services: Program Execution

The document discusses the five main services provided by operating systems: 1) Program execution - The OS provides an environment for users to run programs without worrying about memory allocation or multitasking. 2) I/O operations - The OS handles I/O and hides hardware details from users. 3) File system manipulation - The OS allows reading/writing files without knowledge of storage management. 4) Communications - The OS facilitates communication between processes running on the same or different computers. 5) Error detection - The OS monitors for errors to prevent system malfunctions. It handles errors in a way that protects system integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Operating Systems Services: Program Execution

The document discusses the five main services provided by operating systems: 1) Program execution - The OS provides an environment for users to run programs without worrying about memory allocation or multitasking. 2) I/O operations - The OS handles I/O and hides hardware details from users. 3) File system manipulation - The OS allows reading/writing files without knowledge of storage management. 4) Communications - The OS facilitates communication between processes running on the same or different computers. 5) Error detection - The OS monitors for errors to prevent system malfunctions. It handles errors in a way that protects system integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Operating Systems Services

Following are the five services provided by an operating systems to


the convenience of the users.
Program Execution
The purpose of a computer systems is to allow the user to execute
programs. So the operating systems provides an environment where
the user can opportunely run programs. The user does not have to
worry about the memory allocation or multitasking or anything.
These things are taken care of by the operating systems.
Running a program involves the allocating and deallocating
memory, CPU scheduling in case of multiprocessor. These functions
cannot be given to the user-level programs. So user-level programs
cannot help the user to run programs independently without the
help from operating systems.

I/O Operations
Each program requires an input and produces output. This involves
the use of I/O. The operating systems hides the user the details of
underlying hardware for the I/O. All the user sees is that the I/O has
been performed without any details. So the operating systems by
providing I/O makes it convenient for the users to run programs.
For efficiently and protection users cannot control I/O so this service
cannot be provided by user-level programs.

File System Manipulation

The output of a program may need to be written into new files or


input taken from some files. The operating systems provides this
service. The user does not have to worry about secondary storage
management. User gives a command for reading or writing to a file
and sees his her task accomplished. Thus operating systems makes
it easier for user programs to accomplish their task.
This service involves secondary storage management. The speed of
I/O that depends on secondary storage management is critical to the
speed of many programs and hence I think it is best relegated to the
operating systems to manage it than giving individual users the
control of it. It is not difficult for the user-level programs to provide
these services but for above mentioned reasons it is best if this
service s left with operating system.
Communications
There are instances where processes need to communicate with
each other to exchange information. It may be between processes
running on the same computer or running on the different
computers. By providing this service the operating system relieves
the user of the worry of passing messages between processes. In
case where the messages need to be passed to processes on the
other computers through a network it can be done by the user
programs. The user program may be customized to the specifics of
the hardware through which the message transits and provides the
service interface to the operating system.
Error Detection
An error is one part of the system may cause malfunctioning of the
complete system. To avoid such a situation the operating system
constantly monitors the system for detecting the errors. This
relieves the user of the worry of errors propagating to various part of
the system and causing malfunctioning.
This service cannot allowed to be handled by user programs
because it involves monitoring and in cases altering area of memory
or deallocation of memory for a faulty process. Or maybe
relinquishing the CPU of a process that goes into an infinite loop.
These tasks are too critical to be handed over to the user programs.

A user program if given these privileges can interfere with the


correct (normal) operation of the operating systems.

Q3. Explain in brief about each type of System Call.


Ans. System calls can be grouped roughly into five major categories:
1.

Process Control

2.

File Management

3.

Device Management

4.

Information Maintenance

5.

Communication

1. Process Control
1.

end, abort.

2.

load, execute.

3.

create process, terminate process.

4.

get process attributes, set process attributes.

5.

wait for time.

6.

wait event, signal event.

7.

allocate and free memory.

2. File Management
1. create file, delete file.
2. open, close.
3. read, write, reposition.
4. get file attributes, set file attributes.

3. Device Management
1. request device, release device.
2. read, write, reposition.
3. get device attributes, set device attributes.
4. logically attach or detach devices.

4. Information Maintenance
1. get time or date, set time or date.
2. get system data, set system data.
3. get process, file, or device attributes.
4. set process, file, or device attributes.
5. Communications
1. create, delete communication connection.
2. send, receive messages.
3. transfer status information.
4. attach or detach remote devices.

What is Thread?
A thread is a flow of execution through the process code, with its own
program counter, system registers and stack. A thread is also called a light
weight process. Threads provide a way to improve application performance
through parallelism. Threads represent a software approach to improving
performance of operating system by reducing the overhead thread is
equivalent to a classical process.
Each thread belongs to exactly one process and no thread can exist outside
a process. Each thread represents a separate flow of control.Threads have
been successfully used in implementing network servers and web server.
They also provide a suitable foundation for parallel execution of applications
on shared memory multiprocessors. Folowing figure shows the working of
the single and multithreaded processes.

Difference between Process and Thread


S.N.

Process

Thread

Process is heavy weight or resource


intensive.

Thread is light weight taking lesser


resources than a process.

Process switching needs interaction


with operating system.

Thread switching does not need to


interact with operating system.

In multiple processing environments


each process executes the same code
but has its own memory and file
resources.

All threads can share same set of


open files, child processes.

If one process is blocked then no other


process can execute until the first
process is unblocked.

While one thread is blocked and


waiting, second thread in the
same task can run.

Multiple processes without using


threads use more resources.

Multiple threaded processes use


fewer resources.

In multiple processes each process


operates independently of the others.

One thread can read, write or


change another thread's data.

Advantages of Thread

Thread minimize context switching time.

Use of threads provides concurrency within a process.

Efficient communication.

Economy- It is more economical to create and context switch threads.

Utilization of multiprocessor architectures to a greater scale and efficiency.

Types of Thread
Threads are implemented in following two ways

User Level Threads -- User managed threads

Kernel Level Threads -- Operating System managed threads acting on kernel,


an operating system core.

User Level Threads


In this case, application manages thread management kernel is not aware of
the existence of threads. The thread library contains code for creating and
destroying threads, for passing message and data between threads, for
scheduling thread execution and for saving and restoring thread contexts.
The application begins with a single thread and begins running in that
thread.

Advantages

Thread switching does not require Kernel mode privileges.

User level thread can run on any operating system.

Scheduling can be application specific in the user level thread.

User level threads are fast to create and manage.

Disadvantages

In a typical operating system, most system calls are blocking.

Multithreaded application cannot take advantage of multiprocessing.

Kernel Level Threads


In this case, thread management done by the Kernel. There is no thread
management code in the application area. Kernel threads are supported
directly by the operating system. Any application can be programmed to be
multithreaded. All of the threads within an application are supported within
a single process.
The Kernel maintains context information for the process as a whole and for
individuals threads within the process. Scheduling by the Kernel is done on a
thread basis. The Kernel performs thread creation, scheduling and

management in Kernel space. Kernel threads are generally slower to create


and manage than the user threads.

Advantages

Kernel can simultaneously schedule multiple threads from the same process on
multiple processes.

If one thread in a process is blocked, the Kernel can schedule another thread of
the same process.

Kernel routines themselves can multithreaded.

Disadvantages

Kernel threads are generally slower to create and manage than the user threads.

Transfer of control from one thread to another within same process requires a
mode switch to the Kernel.

Multithreading Models
Some operating system provide a combined user level thread and Kernel
level thread facility. Solaris is a good example of this combined approach. In
a combined system, multiple threads within the same application can run in
parallel on multiple processors and a blocking system call need not block
the entire process. Multithreading models are three types

Many to many relationship.

Many to one relationship.

One to one relationship.

Many to Many Model


In this model, many user level threads multiplexes to the Kernel thread of
smaller or equal numbers. The number of Kernel threads may be specific to
either a particular application or a particular machine.

Following diagram shows the many to many model. In this model,


developers can create as many user threads as necessary and the
corresponding Kernel threads can run in parallels on a multiprocessor.

Many to One Model


Many to one model maps many user level threads to one Kernel level
thread. Thread management is done in user space. When thread makes a
blocking system call, the entire process will be blocked. Only one thread can
access the Kernel at a time,so multiple threads are unable to run in parallel
on multiprocessors.
If the user level thread libraries are implemented in the operating system in
such a way that system does not support them then Kernel threads use the
many to one relationship modes.

One to One Model


There is one to one relationship of user level thread to the kernel level
thread.This model provides more concurrency than the many to one model.
It also another thread to run when a thread makes a blocking system call. It
support multiple thread to execute in parallel on microprocessors.
Disadvantage of this model is that creating user thread requires the
corresponding Kernel thread. OS/2, windows NT and windows 2000 use one
to one relationship model.

Difference between User Level & Kernel Level


Thread
S.N.

User Level Threads

Kernel Level Thread

User level threads are faster to


create and manage.

Kernel level threads are slower to


create and manage.

Implementation is by a thread
library at the user level.

Operating system supports creation


of Kernel threads.

User level thread is generic and can


run on any operating system.

Kernel level thread is specific to the


operating system.

Multi-threaded application cannot


take advantage of multiprocessing.

Kernel routines themselves can be


multithreaded.

You might also like