unit2osy

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

Unit No.

02
Services & Components
of Operating System
Different Services of OS
An operating system (OS) creates a supportive
environment for running programs, offering
various services to both the programs and their
users. These operating system services are
provided for the convenience of the programmer,
to make the programming task easier.
User interface
• Almost all operating systems have a user interface (UI). This
interface can take several forms. One is a command-line
interface (CLI), which uses text commands and a method for
entering them (say, a keyboard for typing in commands in a
specific format with specific options).
• Another is a batch interface, in which commands and
directives to control those commands are entered into files,
and those files are executed. Most commonly, a graphical
user interface (GUI) is used. Here, the interface is a window
system with a pointing device to direct I/O, choose from
menus, and make selections and a keyboard to enter text.
Some systems provide two or all three of these variations.
• Program Execution:
Loading and Running Programs: The operating
system must be capable of loading a program into
memory and executing it.
Termination: The program should be able to
terminate its execution, whether it ends normally
or encounters an error.
 Loads a program into memory.
 Executes the program.
 Handles program's execution.
 Provides a mechanism for process synchronization.
 Provides a mechanism for process communication.
 Provides a mechanism for deadlock handling.
I/O Operations
A running program may require I/O, which may
involve a file or an I/O device.
An I/O subsystem comprises of I/O devices and
their corresponding driver software.
An Operating System manages the communication
between user and device drivers. I/O operation
means read or write operation with any file or any
specific I/O device.
Operating system provides the access to the
required I/O device when required.
File-System Manipulation

File represents a collection of related information.


Computers can store files on the disk (secondary storage),
for long-term storage purpose.
 Reading and Writing Files: Programs need to be able
to read from and write to files and directories.
 File and Directory Management: This includes
creating and deleting files and directories, searching for
files by name, and listing file information.
 Permissions Management: Some operating systems
manage file permissions, allowing or denying access to
files and directories based on ownership.
Communications

 Inter-Process Communication (IPC): In many


scenarios, one process needs to exchange information
with another process.
 Local and Network Communication: This
communication can occur between processes running
on the same computer or on different computers
connected by a network.
 Shared Memory: One method of communication is
shared memory, where two or more processes read from
and write to a common section of memory.
 Message Passing: Another method is message passing,
where packets of information in predefined formats are
moved between processes by the operating system.
Error detection
 The operating system needs to be detecting and correcting
errors constantly.
 Errors may occur in the CPU and memory hardware (such
as a power failure), in I/O devices (such as a connection
failure on a network, or lack of paper in the printer),and
in the user program (such as an arithmetic overflow, an
attempt to access an illegal memory location, or a too-
great use of CPU time).
 For each type of error, the operating system should take
the appropriate action to ensure correct and consistent
computing. Sometimes, it has no choice but to halt the
system. At other times, it might terminate an error causing
process or return an error code to a process for the process
to detect and possibly correct.
Resource allocation
 When there are multiple users or multiple jobs running at the
same time, resources must be allocated to each of them.
 The operating system manages many different types of
resources. Some (such as CPU cycles, main memory, and file
storage) may have special allocation code, whereas others
(such as I/O devices) may have much more general request
and release code.
 For instance, in determining how best to use the CPU,
operating systems have CPU-scheduling routines that take into
account the speed of the CPU, the jobs that must be executed,
the number of registers available, and other factors.
 There may also be routines to allocate printers, USB storage
drives, and other peripheral devices.
Accounting
We want to keep track of which users use how
much and what kinds of computer resources.
This record keeping may be used for accounting
(so that users can be billed) or simply for
accumulating usage statistics. Usage statistics
may be a valuable tool for researchers who wish
to reconfigure the system to improve computing
services.
Protection and security
• Protection refers to a mechanism or a way to control
the access of programs, processes, or users to the
resources defined by a computer system.
• Protection involves ensuring that all access to system
resources is controlled. Security of the system from
outsiders is also important. Such security starts with
requiring each user to authenticate himself or herself
to the system, usually by means of a password, to
gain access to system resources.
System Call
• A system call is a mechanism that allows a
program to request a service from the
operating system's kernel.
• A system call is a way for programs to interact
with the operating system.
• A computer program makes a system call
when it requests the operating system’s kernel.
• Most of these interfaces are written in high-
level languages such as C or C++.
• Programs usually access OS services through a
high-level API rather than making direct
system calls.
• Three most common APIs are Win32 API for
Windows, POSIX API for POSIX-based
systems (including virtually all versions of
UNIX, Linux, and Mac OS X), and Java API
for the Java virtual machine (JVM)
System Call Implementation
1. Each system call is assigned a unique number. For example,
in UNIX-like systems, the read system call might have a
number like 3.
2. When a user-space program makes a system call (e.g., using
the read function), it places the system call number and
arguments in specific CPU registers.
3. The trap instruction transfers control to the system call
handler in the kernel.
4. The system call handler retrieves the system call number
from the CPU register and uses it to index into the system
call table.
5. The system call table entry corresponding to the system call
number contains a pointer to the function that implements the
system call.
6. The kernel function executes the requested operation (e.g.,
reading data from a file).
7. After the kernel function completes, it returns a status code
and any requested data.
• C program invoking printf() library call, which calls write()
system call
• High-Level API (printf): The user program
interacts with the OS indirectly by calling
printf, a high-level function in the standard C
library.
• Library Abstraction (write): The C library
translates the printf call into a lower-level
operation, like write, which interacts with the
OS through a system call.
• System Call (write): The actual system call to
the OS handles the hardware-level operation,
like displaying text on the screen.
Types of System Calls
• Process control
o end, abort
o load, execute
o create process, terminate process
o get process attributes, set process attributes
o wait for time
o wait event, signal event
o allocate and free memory
• File management
o create file, delete file
o open, close file
o read, write
o get and set file attributes
• Device management
o request device, release device
o read, write
o get device attributes, set device attributes
o logically attach or detach devices
• Information maintenance
o get time or date, set time or date
o get system data, set system data
o get and set process, file, or device attributes
• Communications
o create, delete communication connection
o send, receive messages
o transfer status information
o attach and detach remote devices
Component of OS
The components of an operating system are as
follows:
1. Process Management
2. Memory Management
3. Secondary Storage Management
4. I/O Management
5. File Management
1. Process Management
• A process is a program that is actively running on
your computer. Once a program starts executing,
it turns into a process. Examples of processes
include:
• Batch Job: A task that runs in the background
without user interaction.
• Time-Shared Program: A program that runs in a
system where multiple users share the resources.
• System Task: Internal tasks managed by the OS,
like handling print jobs.
Process management is a key responsibility of the operating
system, making sure all processes run smoothly.
• Creating and Deleting Processes: The OS starts
processes when new tasks are needed and stops them
when they're done.
• Suspending and Resuming Processes: The OS can
pause and later restart processes to manage resources
better.
• Process Synchronization: The OS ensures that processes
that share resources work together without conflicts.
• Process Communication: The OS provides ways for
processes to talk to each other, which is important in
systems where multiple processes run at the same time.
• Deadlock Handling: The OS resolves situations where
processes are stuck waiting for each other to release
resources, preventing the system from freezing.
2. Memory Management
• Memory is one of the most expensive components
in a computer system. It consists of a large array
of storage locations, each with a unique address.
• The CPU interacts with memory by reading from
and writing to these specific addresses to execute
programs.
• Memory management is a crucial function of the
operating system, ensuring that memory is used
efficiently and processes have the memory they
need to run.
The OS handles memory management in the
following ways:
1. Tracking Memory Usage: The OS keeps track of
which parts of memory are in use and by which
processes.
2. Loading Processes into Memory: The OS
decides which processes should be loaded into
memory when space becomes available.
3. Allocating and Deallocating Memory: The OS
allocates memory to processes as needed and
frees up memory when it's no longer in use.
3. Secondary Storage Management
• Secondary storage, like disks, is used to store
programs and data that can't fit in the main
memory
• Programs such as compilers, editors, and
others are stored on the disk until they are
needed in memory.
• The disk also serves as the source and
destination for data processing.
• Managing disk storage efficiently is critical
for the computer system. The operating
system (OS) is responsible for:
1. Free Space Management: Keeping track of
available storage space on the disk so that it
can be allocated as needed.
2. Storage Allocation: Assigning disk space to
various files and programs.
3. Disk Scheduling: Determining the order in
which disk read/write requests are processed
to optimize performance.
4. I/O Management
• One of the key roles of an operating system
(OS) is to simplify interactions with hardware
for the user.
• The OS hides the complexities and specific
details of hardware devices, making it easier
for users and applications to perform
input/output (I/O) operations without needing
to understand how the hardware works.
• The OS handles several important tasks related to I/O
management:
1. Buffer Caching System: The OS uses a buffer cache to
temporarily store data being transferred between the
CPU and I/O devices, improving efficiency and
performance.
2. Activating General Device Driver Code: The OS
activates general device drivers, which are programs
that allow the OS to interact with different types of
hardware devices in a standard way.
3. Running Specific Driver Software: When specific
hardware devices are needed, the OS runs the
appropriate driver software to manage communication
with that device, ensuring that data is correctly
transferred between the device and the system.
5. File Management
• A file is essentially a collection of related information, such
as a program or data, defined by its creator.
• Files can vary in format, ranging from free-form text files to
structured data files. Generally, a file is a sequence of bits,
bytes, lines, or records whose structure and meaning are
determined by its creator and user.
• The operating system handles several critical tasks to
manage files and ensure they are stored, organized, and
accessed efficiently:
1. Creation and Deletion of Files: The OS provides the
ability to create new files and delete files that are no longer
needed.
1. Creation and Deletion of Directories: To organize
files, the OS allows the creation of directories (or
folders) and the deletion of unnecessary ones.
2. Support for File and Directory Manipulation: The
OS includes basic operations (primitives) that allow
users to open, close, read, write, rename, and move files
and directories.
3. Mapping of Files onto Disk Storage: The OS manages
the physical storage of files on disks, ensuring that files
are efficiently stored and retrieved.
4. Backup of Files: To protect against data loss, the OS
provides mechanisms to back up files to stable, non-
volatile storage, ensuring data can be recovered if
needed.
5. Protection and Security: The OS controls who can
access files and how they can be accessed, ensuring that
sensitive data is protected from unauthorized access.
2.4 System Tools
Following are the operating tools:
• Security policy
• Device Management
• Performance Monitor
• Task Scheduler
Device manager
• Windows can automatically detect and install. However, for some
specialized or older devices, you may need to manually install
drivers. This can be done by downloading the appropriate driver
from the manufacturer's website or using the "Update driver" option
in Device Manager.
• Device Categories: In Device Manager, devices are grouped into
categories like "Display adapters," "Network adapters," "Sound,
video, and game controllers," etc. This organization makes it easier
to find and manage specific devices.
• Driver Rollback and Update: Device Manager also provides
options to update, disable, or roll back drivers to a previous version
if a new update causes issues.
• Troubleshooting Tools: If a device is not working correctly, Device
Manager often provides a basic diagnostic tool. For example, if a
device has a problem, it will be marked with a yellow triangle icon.
You can right-click the device to view its properties, which may
offer suggestions for troubleshooting.
Performance monitor
• It is the option to actually monitor how the
CPU is performing. One can go there from the
control panel or another easy way to reach
there is by pressing sticky keys on the key
boards. One can press Ctrl, Alt and Del at the
same time, to find the option of Start Task
Manager.
Task scheduler
Task Scheduler in Windows allows users to
automate tasks by scheduling them to run at
specific times or intervals. It can be used to
perform tasks daily, weekly, or on any custom
schedule. To access Task Scheduler, go to
Control Panel > Administrative Tools. It's
available in Windows 7, Vista, and 8 with
updated features, enabling users to automate
without needing additional software.
Local security policy
Local Security Policy is a feature in Windows
(mainly for corporate environments) that allows
administrators to control user access to drives,
software, and websites.
Found under Administrative Tools, it enables setting
permissions, restricting software usage, and
blocking access to certain websites. This helps
maintain security, compliance, and productivity by
limiting what users can do on the system. It's
typically used in larger organizations and is not
available in the Home version of Windows.
Thank you!!!!!!!!!!!!!!!

You might also like