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

Operating System Unit 1

Uploaded by

tahi66438
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Operating System Unit 1

Uploaded by

tahi66438
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Views of Operating System

An operating system is a framework that enables user application programs to interact with
system hardware. The operating system does not perform any functions on its own, but it
provides an atmosphere in which various apps and programs can do useful work. The operating
system may be observed from the point of view of the user or the system, and it is known as
the user view and the system view. In this article, you will learn the views of the operating
system.
Viewpoints of Operating System
The operating system may be observed from the viewpoint of the user or the system. It is
known as the user view and the system view. There are mainly two types of views of the
operating system. These are as follows:
1. User View
2. System View
User View
The user view depends on the system interface that is used by the users. Some systems are
designed for a single user to monopolize the resources to maximize the user's task. In these
cases, the OS is designed primarily for ease of use, with little emphasis on quality and none on
resource utilization.
The user viewpoint focuses on how the user interacts with the operating system through the
usage of various application programs. In contrast, the system viewpoint focuses on how the
hardware interacts with the operating system to complete various tasks.
1. Single User View Point
Most computer users use a monitor, keyboard, mouse, printer, and other accessories to
operate their computer system. In some cases, the system is designed to maximize the output
of a single user. As a result, more attention is laid on accessibility, and resource allocation is less
important. These systems are much more designed for a single user experience and meet the
needs of a single user, where the performance is not given focus as the multiple user systems.
2. Multiple User View Point
Another example of user views in which the importance of user experience and performance is
given is when there is one mainframe computer and many users on their computers trying to
interact with their kernels over the mainframe to each other. In such circumstances, memory
allocation by the CPU must be done effectively to give a good user experience. The client-server
architecture is another good example where many clients may interact through a remote
server, and the same constraints of effective use of server resources may arise.
3. Handled User View Point
Moreover, the touchscreen era has given you the best handheld technology ever. Smartphones
interact via wireless devices to perform numerous operations, but they're not as efficient as a
computer interface, limiting their usefulness. However, their operating system is a great
example of creating a device focused on the user's point of view.
4. Embedded System User View Point
Some systems, like embedded systems that lack a user point of view. The remote control used
to turn on or off the tv is all part of an embedded system in which the electronic device
communicates with another program where the user viewpoint is limited and allows the user to
engage with the application.
System View
The OS may also be viewed as just a resource allocator. A computer system comprises various
sources, such as hardware and software, which must be managed effectively. The operating
system manages the resources, decides between competing demands, controls the program
execution, etc. According to this point of view, the operating system's purpose is to maximize
performance. The operating system is responsible for managing hardware resources and
allocating them to programs and users to ensure maximum performance.
From the user point of view, we've discussed the numerous applications that require varying
degrees of user participation. However, we are more concerned with how the hardware
interacts with the operating system than with the user from a system viewpoint. The hardware
and the operating system interact for a variety of reasons, including:
1. Resource Allocation
The hardware contains several resources like registers, caches, RAM, ROM, CPUs, I/O
interaction, etc. These are all resources that the operating system needs when an application
program demands them. Only the operating system can allocate resources, and it has used
several tactics and strategies to maximize its processing and memory space. The operating
system uses a variety of strategies to get the most out of the hardware resources, including
paging, virtual memory, caching, and so on. These are very important in the case of various user
viewpoints because inefficient resource allocation may affect the user viewpoint, causing the
user system to lag or hang, reducing the user experience.
2. Control Program
The control program controls how input and output devices (hardware) interact with the
operating system. The user may request an action that can only be done with I/O devices; in
this case, the operating system must also have proper communication, control, detect, and
handle such devices.
user and operating system interface
The user and operating system are connected with each other with the help of interface, so
interface is used to connect the user and OS.
In computers there are different types of interface that can be used for connection with
computers to users and their connection is responsible for data transfer.
Also, in computers there are different interfaces. These interfaces are not necessarily used but
can be used in computers whenever it is needed. So, different types of tasks can be performed
by the help of different interfaces.

Command line interface


The command-line interface is an interface whenever the user needs to have different
commands regarding the input and output and then a task is performed so this is called the
command-line argument and it is used to execute the output and create, delete, print, copy,
paste, etc.
All these operations are performed with the help of the command-line interface.
The interface is always connected to the OS so that the command given by the user directly
works by the OS and a number of operations can be performed with the help of the command
line interface because multiple commands can be interrupted at same time and execute only
one.
The command line interface is necessary because all the basic operations in the computer are
performed with the help of the OS and it is responsible for memory management. By using this
we can divide the memory and we can use the memory.
Command Line Interface advantages −
Controls OS or application
faster management
ability to store scripts which helps in automating regular tasks.
Troubleshoot network connection issues.
Command Line Interface disadvantages −
The steeper learning curve is associated with memorizing commands and a complex syntax.
Different commands are used in different shells.

Graphical user interface


The graphical user interface is used for playing games, watching videos, etc. these are done
with the help of GUI because all these applications require graphics.
The GUI is one of the necessary interfaces because only by using the user can clearly see the
picture, play videos.
So we need GUI for computers and this can be done only with the help of an operating system.
When a task is performed in the computer then the OS checks the task and defines the
interface which is necessary for the task. So, we need GUI in the OS.
The basic components of GUIs are −
Start menu with program groups
Taskbar which showing running programs
Desktop screen
Different icons and shortcuts.
Choice of interface
The interface that is used with the help of OS for a particular task and that task can be
performed with minimum possible time and the output is shown on the screen in that case we
use the choice of interface.
The choice of interface means the OS checks the task and finds out which interface can be
suitable for a particular task. So that type of interface is called the choice of interface and this
can be done with the help of an OS.

System Calls in Operating System (OS)


A system call is a way for a user program to interface with the operating system. The program
requests several services, and the OS responds by invoking a series of system calls to satisfy the
request. A system call can be written in assembly language or a high-level language
like C or Pascal. System calls are predefined functions that the operating system may directly
invoke if a high-level language is used.
What is a System Call?
A system call is a method for a computer program to request a service from the kernel of
the operating system on which it is running. A system call is a method of interacting with the
operating system via programs. A system call is a request from computer software to an
operating system's kernel.
The Application Program Interface (API) connects the operating system's functions to user
programs. It acts as a link between the operating system and a process, allowing user-level
programs to request operating system services. The kernel system can only be accessed using
system calls. System calls are required for any programs that use resources.
How are system calls made?
When a computer software needs to access the operating system's kernel, it makes a system
call. The system call uses an API to expose the operating system's services to user programs. It
is the only method to access the kernel system. All programs or processes that require
resources for execution must use system calls, as they serve as an interface between the
operating system and user programs.
Below are some examples of how a system call varies from a user function.
1. A system call function may create and use kernel processes to execute the
asynchronous processing.
2. A system call has greater authority than a standard subroutine. A system call with
kernel-mode privilege executes in the kernel protection domain.
3. System calls are not permitted to use shared libraries or any symbols that are not
present in the kernel protection domain.
4. The code and data for system calls are stored in global kernel memory.
Why do you need system calls in Operating System?
There are various situations where you must require system calls in the operating system.
Following of the situations are as follows:
1. It is must require when a file system wants to create or delete a file.
2. Network connections require the system calls to sending and receiving data packets.
3. If you want to read or write a file, you need to system calls.
4. If you want to access hardware devices, including a printer, scanner, you need a system
call.
5. System calls are used to create and manage new processes.
How System Calls Work
The Applications run in an area of memory known as user space. A system call connects to the
operating system's kernel, which executes in kernel space. When an application creates a
system call, it must first obtain permission from the kernel. It achieves this using an interrupt
request, which pauses the current process and transfers control to the kernel.
If the request is permitted, the kernel performs the requested action, like creating or deleting a
file. As input, the application receives the kernel's output. The application resumes the
procedure after the input is received. When the operation is finished, the kernel returns the
results to the application and then moves data from kernel space to user space in memory.
A simple system call may take few nanoseconds to provide the result, like retrieving the system
date and time. A more complicated system call, such as connecting to a network device, may
take a few seconds. Most operating systems launch a distinct kernel thread for each system call
to avoid bottlenecks. Modern operating systems are multi-threaded, which means they can
handle various system calls at the same time.
Types of System Calls
There are commonly five types of system calls. These are as follows:

• Process Control
• File Management
• Device Management
• Information Maintenance
• Communication
Now, you will learn about all the different types of system calls one-by-one.
Process Control
Process control is the system call that is used to direct the processes. Some process control
examples include creating, load, abort, end, execute, process, terminate the process, etc.
File Management
File management is a system call that is used to handle the files. Some file management
examples include creating files, delete files, open, close, read, write, etc.
Device Management
Device management is a system call that is used to deal with devices. Some examples of device
management include read, device, write, get device attributes, release device, etc.
Information Maintenance
Information maintenance is a system call that is used to maintain information. There are some
examples of information maintenance, including getting system data, set time or date, get time
or date, set system data, etc.
Communication
Communication is a system call that is used for communication. There are some examples of
communication, including create, delete communication connections, send, receive messages,
etc.

Operating System Structure


Exo-Kernel Structure
Exokernel is an operating system developed at MIT to provide application-level management
of hardware resources. By separating resource management from protection, the exokernel
architecture aims to enable application-specific customization. Due to its limited operability,
exokernel size typically tends to be minimal.
The OS will always have an impact on the functionality, performance, and scope of the apps
that are developed on it because it sits in between the software and the hardware. The
exokernel operating system makes an attempt to address this problem by rejecting the notion
that an operating system must provide abstractions upon which to base applications. The
objective is to limit developers use of abstractions as little as possible while still giving them
freedom.
Advantages of Exo-Kernel

• Support for improved application control.


• Separates management from security.
• It improves the performance of the application.
• A more efficient use of hardware resources is made possible by accurate resource
allocation and revocation.
• It is simpler to test and create new operating systems.
• Each user-space program is allowed to use a custom memory management system.
Disadvantages of Exo-Kernel

• A decline in consistency.
• Exokernel interfaces have a complex architecture.

Hybrid Kernel Systems


Pros of Hybrid Kernel Systems:

• Performance Optimization: Combines the speed of monolithic kernels with microkernel


modularity.
• Modularity and Flexibility: Allows updates and maintenance of user-space components
without system reboots.
• Improved Security: Isolates some services in user space, reducing risk of system-wide
crashes.
• Enhanced Stability: User-space crashes do not typically affect the entire system.
• Scalability: Adaptable to various hardware architectures.
Cons of Hybrid Kernel Systems:

• Complexity: More complex to design and manage due to coordination between kernel
and user-space.
• Performance Overhead: Switching between kernel and user modes can introduce
delays.
• Increased Development Time: More time-consuming to develop and debug.
• Less Mature Ecosystem: Fewer tools and community support compared to simpler
architectures.
• Potential Security Flaws: Increased complexity may lead to more subtle security
vulnerabilities.

Process Scheduling
The process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process on the basis of a particular
strategy.
Types of Process Schedulers
There are three types of process schedulers:
1. Long Term or Job Scheduler
It brings the new process to the ‘Ready State’. It controls the Degree of Multi-programming,
i.e., the number of processes present in a ready state at any point in time. It is important that
the long-term scheduler make a careful selection of both I/O and CPU-bound processes. I/O-
bound tasks are which use much of their time in input and output operations while CPU-
bound processes are which spend their time on the CPU. The job scheduler increases
efficiency by maintaining a balance between the two. They operate at a high level and are
typically used in batch-processing systems.
2. Short-Term or CPU Scheduler
It is responsible for selecting one process from the ready state for scheduling it on the
running state. Note: Short-term scheduler only selects the process to schedule it doesn’t load
the process on running. Here is when all the scheduling algorithms are used. The CPU
scheduler is responsible for ensuring no starvation due to high burst time processes.
Short Term Scheduler
The dispatcher is responsible for loading the process selected by the Short-term scheduler on
the CPU (Ready to Running State) Context switching is done by the dispatcher only. A
dispatcher does the following:

• Switching context.
• Switching to user mode.
• Jumping to the proper location in the newly loaded program.
3. Medium-Term Scheduler
It is responsible for suspending and resuming the process. It mainly does swapping (moving
processes from main memory to disk and vice versa). Swapping may be necessary to improve
the process mix or because a change in memory requirements has overcommitted available
memory, requiring memory to be freed up. It is helpful in maintaining a perfect balance
between the I/O bound and the CPU bound. It reduces the degree of multiprogramming.

Multithreading Models in Process Management


There are two main threading models in process management: user-level threads and kernel-
level threads.
User-level threads: In this model, the operating system does not directly support threads.
Instead, threads are managed by a user-level thread library, which is part of the application.
The library manages the threads and schedules them on available processors. The advantages
of user-level threads include greater flexibility and portability, as the application has more
control over thread management. However, the disadvantage is that user-level threads are
not as efficient as kernel-level threads, as they rely on the application to manage thread
scheduling.
Kernel-level threads: In this model, the operating system directly supports threads as part of
the kernel. Each thread is a separate entity that can be scheduled and executed independently
by the operating system. The advantages of kernel-level threads include better performance
and scalability, as the operating system can schedule threads more efficiently. However, the
disadvantage is that kernel-level threads are less flexible and portable than user-level threads,
as they are managed by the operating system.
hybrid models:There are also hybrid models that combine elements of both user-level and
kernel-level threads. For example, some operating systems use a hybrid model called the
“two-level model”, where each process has one or more user-level threads, which are
mapped to kernel-level threads by the operating system.
Overall, the choice of threading model depends on the requirements of the application and
the capabilities of the underlying operating system.
User-level threads:
Advantages:
Greater flexibility and control: User-level threads provide more control over thread
management, as the thread library is part of the application. This allows for more
customization and control over thread scheduling.
Portability: User-level threads can be more easily ported to different operating systems, as
the thread library is part of the application.
Disadvantages:
Lower performance: User-level threads rely on the application to manage thread scheduling,
which can be less efficient than kernel-level thread scheduling. This can result in lower
performance for multithreaded applications.
Limited parallelism: User-level threads are limited to a single processor, as the application has
no control over thread scheduling on other processors.
Kernel-level threads:
Advantages:
Better performance: Kernel-level threads are managed by the operating system, which can
schedule threads more efficiently. This can result in better performance for multithreaded
applications.
Greater parallelism: Kernel-level threads can be scheduled on multiple processors, which
allows for greater parallelism and better use of available resources.
Disadvantages:
Less flexibility and control: Kernel-level threads are managed by the operating system, which
provides less flexibility and control over thread management compared to user-level threads.
Less portability: Kernel-level threads are more tightly coupled to the operating system, which
can make them less portable to different operating systems.
Hybrid models:
Advantages:
Combines advantages of both models: Hybrid models combine the advantages of user-level
and kernel-level threads, providing greater flexibility and control while also improving
performance.
More scalable: Hybrid models can scale to larger numbers of threads and processors, which
allows for better use of available resources.
Disadvantages:
More complex: Hybrid models are more complex than either user-level or kernel-level
threading, which can make them more difficult to implement and maintain.
Requires more resources: Hybrid models require more resources than either user-level or
kernel-level threading, as they require both a thread library and kernel-level support.
Many-to-One Model Example:
in Early Unix Systems
In early Unix systems, threading was sometimes implemented using a many-to-one model. This
approach involved creating multiple user-level threads that were managed by a user-space
threading library. All these user-level threads were then mapped to a single kernel thread

One to one Model:


Real-World Example: Web Servers
Web servers like Apache and Nginx use threading models to handle multiple client requests
concurrently. In a one-to-one threading model, each incoming client request is handled by a
separate thread. This approach provides high concurrency and can effectively utilize multi-core
systems.
Advantages
True Parallelism: Threads can run in parallel on multiple processors, improving performance.
Non-Blocking: Blocking operations in one thread do not affect the execution of other threads.
Kernel-Level Scheduling: The operating system's scheduler can efficiently manage and balance
the load across processors.
Disadvantages
Higher Overhead: Each thread requires kernel resources, leading to higher memory and
processing overhead.
Scalability Limits: Creating too many threads can lead to resource exhaustion and performance
degradation.
Many-to-Many Model in Multithreading
Pros:

• Enhanced Concurrency: Supports multiple user-level threads running concurrently.


• Efficient Resource Utilization: Balances load across multiple CPU cores.
• Reduced Blocking Impact: Other threads can continue executing if one blocks.
• Scalability: Scales well with multi-core processors and many threads.
• Flexibility in Thread Management: Allows fine-tuned control over threads.
• Better Load Balancing: Distributes kernel threads effectively across CPUs.
Cons:

• Complexity: More complex to implement and manage.


• Overhead: Increased overhead from managing multiple threads.
• Potential for Context Switching Overhead: Can incur performance costs.
• Resource Consumption: Higher memory and CPU usage.
• Debugging and Synchronization: More challenging to debug and synchronize.
• Kernel Dependency: Relies on kernel's efficiency in managing threads.

Example: NPTL in Linux


NPTL (Native POSIX Thread Library) is the threading library used in modern Linux systems that
implements the many-to-many threading model.
Disadvantages of Multithreading in OS:

• A multithreading system operates without interruptions.


• The code might become more intricate to comprehend.
• The costs associated with handling various threads could be excessive for
straightforward tasks.
• Identifying and resolving problems may become more demanding due to the intricate
nature of the code.

You might also like