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

OPS Unit 01 Notes

Operating system notes

Uploaded by

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

OPS Unit 01 Notes

Operating system notes

Uploaded by

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

❖ Operating System Services:

⎯ The OS coordinates the use of the hardware and application programs for
various users. It provides a platform for other application programs to work.
⎯ The operating system is a set of special programs that run on a computer system
that allows it to work properly.
⎯ It controls input-output devices, execution of programs, managing files, etc.
⎯ Services of Operating System:
1. Program Execution
2. Input Output Operations
3. File Management
4. Error Handling
5. Resource Management
6. Communication between Processes
1. Program Execution:

⎯ It is the Operating System that manages how a program is going to be executed.


It loads the program into the memory after which it is executed. The order in which
they are executed depends on the CPU Scheduling Algorithms.
⎯ A few are FCFS, SJF, etc. When the program is in execution, the Operating
System also handles deadlock i.e. no two processes come for execution at the same
time.
⎯ The Operating System is responsible for the smooth execution of both user and
system programs.
2. Input Output Operations:

⎯ Operating System manages the input-output operations and establishes


communication between the user and device drivers.
⎯ Device drivers are software that is associated with hardware that is being
managed by the OS so that the sync between the devices works properly.

3. File Management:
⎯ The operating system helps in managing files also. If a program needs
access to a file, it is the operating system that grants access. These
permissions include read-only, read-write, etc.
⎯ It also provides a platform for the user to create, and delete files. The
Operating System is responsible for making decisions regarding the
storage of all types of data or files, i.e, floppy disk/hard disk/pen drive,
etc.
4. Error Handling:
⎯ The Operating System also handles the error occurring in the CPU, in
Input-Output devices, etc.
⎯ It also ensures that an error does not occur frequently and fixes the errors. It
also prevents the process from coming to a deadlock.
5. Resource Management:
⎯ System resources are shared between various processes. It is the
Operating system that manages resource sharing.
⎯ It also manages the CPU time among processes using CPU Scheduling
Algorithms.
⎯ It also helps in the memory management of the system.
⎯ It also controls input-output devices.

6. Communication between processes:


⎯ The Operating system manages the communication between processes.
Communication between processes includes data transfer among them.
⎯ If the processes are not on the same computer but connected through a
computer network, then also their communication is managed by the
Operating System itself.
7. Security and protection:
⎯ In an operating system, protection is a mechanism that controls the access
of the process, programs, or users over any resources of the computer
system.
⎯ The operating system ensures that all access to system resources must be
monitored and controlled.
⎯ It also ensures that the external resources or peripherals must be protected
from invalid access.
⎯ It provides authentication by using usernames and passwords.

❖ Virtual Machines in Operating System:


⎯ virtual machine (VM) is a virtual environment which functions as a
virtual computer system with its own CPU, memory, network interface,
and storage, created on a physical hardware system.
⎯ It has its own operating system and software that will facilitate the
resources to virtual computers.
⎯ The characteristics of the virtual machines are as follows −

• Multiple OS systems use the same hardware and partition resources


between virtual computers.
• Separate Security and configuration identity.
• Ability to move the virtual computers between the physical host
computers as holistically integrated files.
• The below diagram shows you the difference between the single OS with
no VM and Multiple OS with VM −

❖ System Calls
⎯ 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.
⎯ 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.
⎯ 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.
➢ Types of System Calls

There are commonly five types of system calls. These are as follows:

1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication

1.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.

2.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.
3.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.

4.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.

5.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.

Examples of system calls

1.open()
⎯ The open() system call allows you to access a file on a file system. It allocates
resources to the file and provides a handle that the process may refer to.

t is used to obtain data from a file on the file system. It accepts three arguments in
general:

o A file descriptor. o A buffer to store read


data. o The number of bytes to read from the
file.
The file descriptor of the file to be read could be used to identify it and open it using
open() before reading.

2.wait()

In some systems, a process may have to wait for another process to complete its
execution before proceeding. When a parent process makes a child process, the parent
process execution is suspended until the child process is finished. The wait() system
call is used to suspend the parent process. Once the child process has completed its
execution, control is returned to the parent process.

3.write()

It is used to write data from a user buffer to a device like a file. This system call is one
way for a program to generate data. It takes three arguments in general:

o A file descriptor.
o A pointer to the buffer in which data is saved. o The number of
bytes to be written from the buffer.
4.fork()

Processes generate clones of themselves using the fork() system call. It is one of the
most common ways to create processes in operating systems. When a parent process
spawns a child process, execution of the parent process is interrupted until the child
process completes. Once the child process has completed its execution, control is
returned to the parent process.
5.close()

It is used to end file system access. When this system call is invoked, it signifies that
the program no longer requires the file, and the buffers are flushed, the file
information is altered, and the file resources are de-allocated as a result.

6.exec()

When an executable file replaces an earlier executable file in an already executing


process, this system function is invoked. As a new process is not built, the old process
identification stays, but the new process replaces data, stack, data, head, etc.

7.exit()

The exit() is a system call that is used to end program execution. This call indicates
that the thread execution is complete, which is especially useful in multi-threaded
environments. The operating system reclaims resources spent by the process following
the use of the exit() system function.

❖ Kernel Architecture
⎯ Kernel is central component of an operating system that manages operations of
computer and hardware.
⎯ Kernel loads first into memory when an operating system is loaded and remains
into memory until operating system is shut down again. It is responsible for
various tasks such as disk management, task management, and memory
management.
⎯ A kernel must be fast and responsive. It needs to handle all the requests and
responses quickly and efficiently. To do this, the Kernel uses a lot of
kernellevel memory.
⎯ This memory is isolated from the main memory of your computer. This means
that the Kernel can use it to store data and code without affecting other
applications.
⎯ The Kernel controls everything that goes on in your computer, from launching
applications to managing your files. The Kernel is also responsible for security,
ensuring unauthorized users can’t access your system.

Advantages of the Kernel

⎯ It is responsible for managing the system’s resources, including memory,


processors, and devices.

Disadvantages of the Kernel


⎯ 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.

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 0 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
• The mode bit is changed from 0 to 1 in case of the system switch back to
user mode.

Types of the Kernel

1. Simple structure:

⎯ Such operating systems do not have well defined structure and are small,
simple and limited systems. The interfaces and levels of functionality are
not well separated. MS-DOS is an example of such operating system.
⎯ In MS-DOS application programs are able to access the basic I/O routines.
⎯ These types of operating system cause the entire system to crash if one of
the user programs fails. Advantages of Simple structure:
• It delivers better application performance because of the few interfaces
between the application program and the hardware.
• Easy for kernel developers to develop such an operating system.
Disadvantages of Simple structure:
• The structure is very complicated as no clear boundaries exists between
modules.
• It does not enforce data hiding in the operating system.

1. Layered Struture:

⎯ An OS can be broken into pieces and retain much more control on


system. In this structure the OS is broken into number of layers
(levels).
⎯ The bottom layer (layer 0) is the hardware and the topmost layer (layer
N) is the user interface.
⎯ These layers are so designed that each layer uses the functions of the
lower level layers only.
⎯ This simplifies the debugging process as if lower level layers are
debugged and an error occurs during debugging then the error must
be on that layer only as the lower level layers have already been
debugged.
⎯ The main disadvantage of this structure is that at each layer, the data
needs to be modified and passed on which adds overhead to the
system.
⎯ Advantages of Layered structure:
• Layering makes it easier to enhance the operating system as implementation
of a layer can be changed easily without affecting the other layers.
• It is very easy to perform debugging and system verification.
• Disadvantages of Layered structure:
• In this structure the application performance is degraded as compared to
simple structure.
• It requires careful planning for designing the layers as higher layers use the
functionalities of only the lower layers.

3. Micro-kernel:
This structure designs the operating system by removing all
nonessential components from the kernel and implementing them as
system and user programs. This result in a smaller kernel called the
micro-kernel.
Advantages of this structure are that all new services need to be added to
user space and does not require the kernel to be modified.
Thus it is more secure and reliable as if a service fails then rest of the
operating system remains untouched. Mac OS is an example of this type
of OS.
Advantages of Micro-kernel structure:
• It makes the operating system portable to various platforms.
• As microkernels are small so these can be tested effectively.
• Disadvantages of Micro-kernel structure:
• Increased level of inter module communication degrades system
performance.
4. Monolithic Kernel:

⎯ In Monolithic kernel mode, operating system runs in a single address


space.
⎯ Monolithic kernel has all the operating system functions or services
within a single kernel. This single kernel will run as a single process
in a single address space in memory.
⎯ Monolithic architecture enables higher performance however less
flexible for modifications to add new features or enhance existing
features.

Examples:
Windows 1, Windows 2, Windows 3, Windows 95, Windows 98,

All Linux distribtions - CentOS, Ubuntu, Red Hat's Fedora, Red Hat
Enterprise, Open SUSE and all other linux distributions

• Android uses a modified Linux Kernel

You might also like