You are on page 1of 10

Program: Computer Engineering (NBA Accredited)

E-Notes

Operating System (22516) Ch-2 Services and components of Operating System Marks: 10

Q. Explain any six services of Operating System. Draw diagram of services of OS – 6m


 Program Execution: system capability to load a program into memory and to run it.
 I/O operations: since user programs cannot execute I/O operations directly, the operating system
must provide some means to perform I/O.
 File-system manipulation: program capability to read, write, create, and delete files. Maintain details
of files or directories with their respective details.
 Communications: exchange of information between processes executing either on the same
computer or on different systems tied together by a network. Implemented via shared memory or
message passing.
 Error Detection: ensure correct computing by detecting errors in the CPU and memory hardware, in
I/O devices, or in user programs.
 Resource Allocation: allocating resources to multiple users or multiple jobs running at the same time.
Coordinating among peripherals.
 Accounting: keep track of and record which users use how much and what kinds of computer
resources for account billing or for accumulating usage statistics.
 Protection: ensuring that all access to system resources is controlled.
 Security: Providing protection to program, data, and files and to ensure data security.

Q. What is system call?- 2m


System call is an interface between a running program and operating system. It allows user to access services
provided by operating system. This system calls are procedures written using C, C++ and assembly language
instructions. Each operating system has its own name for each system call. Each system call is associated with
a number that identifies itself.

Q. Explain execution of system call with diagram – 4m


System call is an interface between a running program and operating system. It allows user to access services
provided by operating system. This system calls are procedures written using C, C++ and assembly language
instructions. Each operating system has its own name for each system call.
 Each system calls associated with a particular number.
 System call interface maintains a table indexed according to these numbers.
 The system call interface invokes intended system call in operating system kernel and returns status of
the system call and any return values.
 The caller needs to know nothing about how the system call is implemented. Just needs to obey API
and understand what OS will do as a result call.
 Most details of operating system interface hidden from programmers by API. It is managed by run-
time support library.
VTP-SAV Operating System(22516) Chapter-2
1
Program: Computer Engineering (NBA Accredited)
E-Notes

Open ( ) system call for most file systems, a program initializes access to a file in a file system using the open
system call. This allocates resources associated to the file (the file descriptor), and returns a handle that the
process will use to refer to that file.

Q. State any four types of system call provided by an Operating System – 4m


System calls related to Process Control: End, Abort Load, Execute, create process, terminate process, Ready
process, Dispatch process, Suspend, Resume, Get Process attribute, set attribute, Wait for time, Wait event,
signal event.
System calls Related to File Management: Create file, delete file Open file, Close file, Create directory Read,
Write, Reposition Get file attribute, set file attribute, Create a link, Change the working directory.
System calls Related to Device Management: Request a device, release a device Read, Write, Reposition, Get
device attribute, Set device attribute
System calls Related to Information Maintenance: Get Time or Date, Set Time or Date, Get System data, Set
system data, Get process, file or device attributes, Set Process, file or Device attributes.
System calls Related to Communication: create, delete communication connection send, receive messages,
transfer status information, attach or detach remote devices

Q. Explain any four file related system calls – 4m


System calls Related to File management:
 Create file: This system call is used to create a new file in any application.
 Delete file: This system call is used to delete a specific file from the given directory.
 Open file: This system call is used to open an existing file.
 Close file: This system call is used to close an already opened file.
 Read file: This system call is used to read a file which is already opened. By using this system call any
information which is desired can be read from the file.
 Write file: This system call is used to write some data to a file.
 Reposition file: It means to change the position of a file pointer within the file. If there are many
numbers of pages in a file then we can move forward or backward to any position within that file.
 Get file attribute: A file has certain attributes like file_name, file_type, file_size, date of creation,
modification, access permission etc. By using this system call we can check any of the attributes of a
particular file.
 Set file attribute: With the help of this system call, any of the attributes which can be modified or
changed can be “SET”.

VTP-SAV Operating System(22516) Chapter-2


2
Program: Computer Engineering (NBA Accredited)
E-Notes

Q. Explain Types of System Calls


System calls can be grouped roughly into five major categories:
 Process or Job control
 File Management
 Device Management
 Information Maintenance
 Communication

1. Process and Job Control: A running program needs to be able to halt its execution either normally (end) or
abnormally (abort). If the program discovers an error in its input and wants to terminate abnormally, it may
also want to define an error level. A process or job executing one program may want to load and execute
another program. This allows the control card interpreter to execute program as directly by the control cards
of the user job. If we create a new job or process, we should able to control its execution. We may also want
to terminate a job or process that we created (terminate process). If we find that it is incorrect or no longer
needed we need waiting time to finish execution (wait time). Another set of system calls are helpful in
debugging a program.
Example of Process related system call:
 End, Abort
 Load, Execute
 Create process, Terminate process
 Ready process, Dispatch process
 Suspend process, Resume process
 Get process attributes, Set process attributes
 Wait for Time
 Wait event, Signal event
 Change priority of process

2. File Management: We can identify several common system calls dealing with files. We first need to be able
to create and delete files such a system call requires the name of the file and perhaps some of its attributes.
Once the file is created, we need to open it and use it. We may also read, write and reposition. Finally we need
to close the file, indicating that we are no longer using it.
We may need these same sets of operations for directories it we have a directory structure in the file
system. In addition for either files or directories we need to be able to determine the values of various
attributes and perhaps reset them if necessary. File attributes include the file name, a file type, protection
codes, accounting information and so on. Two system calls get file attributes and set file attributes are
required for this function. Some operating systems provide many more calls, such as calls for file move and
copy.
Example of file related system call:
 Create file, Delete file
 Open a file, Close a file
 Create directory
 Read, Write, Reposition
 Get file attributes, Set file attributes
 Create a link
 Change working directory

3. Device Management: Files can be thought of as abstract or virtual devices. Thus many of the system calls
for files are also needed for devices. If there are multiple users of the system however we must first request
the device to ensure that we have exclusive use of it. After we are finished with the device, we must release it.
These functions are similar to the open/close system calls for files.

VTP-SAV Operating System(22516) Chapter-2


3
Program: Computer Engineering (NBA Accredited)
E-Notes

Once, the device has been requested we can read, write and reposition the device just as with files. In
fact the similarity between input/output devices and files is so great that many operating systems merge the
two into a combined file/device structure. In this case input/output devices are identified by special file
names.
System call related to device management:
 Request device, Release device
 Read, Write, Reposition
 Get device attributes, set device attributes

4. Information Maintenance: Many system calls exist simply for the purpose of transferring information
between the user program and the operating system. For example, most systems have a system call to return
the current time and date. Other system calls may return information about the system such as the number of
current users, the version number of the operating system, the amount of free memory or disk space and so
on.
In addition the operating system keeps information about all of its jobs and processes and there are
system calls to access this information. Generally, there are also calls to reset it. (get process attributes and
set process attributes).
Information Maintenance related system call
 Get Time or Date, Set Time or Date
 Get system Data, Set system Data
 Get process, File or Device attributes
 Set process, File or Device attributes

5. Communication: There are two models of inter-process communication, the message-passing model and
the shared memory model.
 Message-passing uses a common mailbox to pass messages between processes: In the message-
passing model, the communicating processes exchange messages with one another to transfer
information. Messages can be exchanged between the processes either directly or indirectly through a
common mailbox. Before communication can take place, a connection must be opened. The name of
the other communicator must be known, be it another process on the same system or a process on
another computer connected by a communications network. Each computer in a network has a host
name by which it is commonly known. A host also has a network identifier, such as an IP address.
Similarly, each process has a process name, and this name is translated into an identifier by which the
operating system can refer to the process. The get hostid and get processid system calls do this
translation. The identifiers are then passed to the general purpose open and close calls provided by
the file system or to specific open connection and close connection system calls, depending on the
system’s model of communication. The recipient process usually must give its permission for
communication to take place with an accept connection call. Most processes that will be receiving
connections are special-purpose daemons, which are systems programs provided for that purpose.
They execute a wait for connection call and are awakened when a connection is made. The source of
the communication, known as the client, and the receiving daemon, known as a server, then exchange
messages by using read message and write message system calls. The close connection call
terminates the communication.
 Shared memory use certain system calls to create and gain access to regions of memory owned by
other processes. : The two processes exchange information by reading and writing in the shared data.
In the shared-memory model, processes use shared memory create and shared memory attach
system calls to create and gain access to regions of memory owned by other processes. Recall that,
normally, the operating system tries to prevent one process from accessing another process’s
memory. Shared memory requires that two or more processes agree to remove this restriction. They
can then exchange information by reading and writing data in the shared areas. The form of the data
and the location are determined by the processes and are not under the operating system’s control.

VTP-SAV Operating System(22516) Chapter-2


4
Program: Computer Engineering (NBA Accredited)
E-Notes

The processes are also responsible for ensuring that they are not writing to the same location
simultaneously.

Message passing is useful for exchanging smaller amounts of data, because no conflicts need be avoided. It is
also easier to implement than is shared memory for inter-computer communication. Shared memory allows
maximum speed and convenience of communication, since it can be done at memory speeds when it takes
place within a computer. Problems exist, however, in the areas of protection and synchronization between the
processes sharing memory

Communication related system calls:


 Establish a connection
 Send, receive messages
 Terminate a connection

Q. What is Process Management? State any four functions of process management – 4m


A process is a program in execution. The operating system manages many kinds of activities ranging from user
programs to System programs like printer spooler, name servers, file server etc. Each of these activities is
encapsulated in a process. A process includes the complete execution context (code, data, PC, registers, OS
resources in use etc.). A process needs certain resources like CPU time, memory I/O devices and file to
accomplish its task. These resources are provided when process is created or allocated while it is running. The
execution of a process must be sequential. The CPU executes instructions one after another, until the process
completes.

The major activities/functions of an operating system in regard to process management are:


 Creation and deletion of user and system processes.
 Suspension and resumption of processes.
 A mechanism for process synchronization.
 A mechanism for process communication.
 A mechanism for deadlock handling.

Q. Explain different activities of I/O system management components of OS - 4m


I/O System: Input / Output device management provides an environment for the better interaction between
system and the I / O devices such as printers, scanners, tape drives etc. To interact with I/O devices in an
effective manner, the operating system uses some special programs known as device driver. The device
drivers take the data that operating system has defined as a file and then translate them into streams of bits
or a series of laser. A device driver is a specific type of computer software that is developed to allow
interaction with hardware devices. Typically, this continues an interface for communicating with the I/O
device, through the specific computer bus or communication subsystem that the hardware is connected with.
The device driver is a
specialized hardware dependent computer program that enables another program, typically an operating
system to interact transparently with a hardware device, and usually provides the required interrupt handling
necessary for the time dependent hardware interfacing.
Activities:
 Providing interfaces to other system components.
 Managing devices
 Transferring data
 Detecting I/O completion

VTP-SAV Operating System(22516) Chapter-2


5
Program: Computer Engineering (NBA Accredited)
E-Notes

Explain Main Memory Management components of OS with its activities – 4m


 Main-Memory is a large array of words or bytes.
 Each word or byte has its own address.
 Main memory provides storage that can be access directly by the CPU.
 That is to say for a program to be executed, it must in the main memory.

The major activities of an operating in regard to memory-management are:


 Keep track of which part of memory are currently being used and by whom.
 Decide which processes are loaded into memory when memory space becomes available.
 Allocate memory space as needed Deallocate memory space as needed

Secondary-Storage Management:
Systems have several levels of storage, including primary storage, secondary storage and cache storage.
Instructions and data must be placed in primary storage or cache to be referenced by a running program.
Because main memory is too small to accommodate all data and programs, and its data are lost when power is
lost, the computer system must provide secondary storage to back up main memory. Secondary storage
consists of tapes, Disks, and other media designed to hold information that will eventually be accessed in
primary storage (primary, secondary, cache) is ordinarily divided into bytes or words consisting of a fixed
number of bytes. Each location in storage has an address; the set of all addresses available to a program is
called an address space. The three major activities of an operating system in regard to secondary storage
management are:
 Managing the free space available on the secondary-storage device
 Allocation of storage space when new files have to be written.
 Scheduling the requests for memory access.

Q. Enlist system components. Describe any two in detail – 4m


List of System Components:
1. Process management
2. Main memory management
3. File management
4. I/O system management
5. Secondary storage management

1. Process Management:
The operating system manages many kinds of activities ranging from user programs to system programs like
printer spooler, name servers, file server etc. Each of these activities is encapsulated in a process. A process
includes the complete execution context (code, data, PC, registers, OS resources in use etc.). The basic unit of
software that the operating system deals with in scheduling the work done by the processor is either a process
or a thread, depending on the operating system. It’s tempting to think of a process as an application, but that
gives an incomplete picture of how processes relate to the operating system and hardware. The application
you see (word processor or spreadsheet or game) is, indeed, a process, but that application may cause several
other processes to begin, for tasks like communications with other devices or other computers. There are also
numerous processes that run without giving you direct evidence that they ever exist. A process, then, is
software that performs some action and can be controlled by a user, by other applications or by the operating
system. It is processes, rather than applications, that the operating system controls and schedules for
execution by the CPU. In a single-tasking system, the schedule is straightforward. The operating system allows
the application to begin running, suspending the execution only long enough to deal with interrupts and user
input.

VTP-SAV Operating System(22516) Chapter-2


6
Program: Computer Engineering (NBA Accredited)
E-Notes

The five major activities of an operating system in regard to process management are
1. Creation and deletion of user and system processes.
2. Suspension and resumption of processes.
3. A mechanism for process synchronization.
4. A mechanism for process communication.
5. A mechanism for deadlock handling.

2. Main-Memory Management
Services provided under Memory Management are directed to keeping track of memory and allocating/de
allocating it to various processes. The OS keeps a list of free memory locations. Before a program is loaded in
the memory from the disk, this MM consults the free list, allocates the memory to the process, depending
upon the program size and updates the list of free memory. Primary-Memory or Main-Memory is a large array
of words or bytes. Each word or byte has its own address. Main-memory provides storage that can be access
directly by the CPU. That is to say for a program to be executed, it must in the main memory.

The major activities of an operating in regard to memory-management are:


1. Keeping track of which parts of memory are currently being used and by whom.
2. Deciding which processes (or parts thereof) and data to move into and out of memory.
3. Allocating and deallocating memory space as needed.

3. File Management
A file is a collected of related information defined by its creator. Computer can store files on the disk
(secondary storage), which provide long term storage. Some examples of storage media are magnetic tape,
magnetic disk and optical disk. Each of these media has its own properties like speed, capacity, and data
transfer rate and access methods. A file system normally organized into directories to ease their use. These
directories may contain files and other directions.
The five main major activities of an operating system in regard to file management are
1. The creation and deletion of files.
2. The creation and deletion of directions.
3. The support of primitives for manipulating files and directions.
4. The mapping of files onto secondary storage.
5. The backup of files on stable storage media.

4. I/O device Management


Input / Output device management provides an environment for the better interaction between system and
the I / O devices. To interact with I/O devices in an effective manner, the operating system uses some special
programs known as device driver. The device drivers take the data that operating system has defined as a file
and then translate them into streams of bits or a series of laser pulses. The device driver is a specialized
hardware dependent computer program that enables another program, typically an operating system to
interact transparently with a hardware device, and usually provides the required interrupt handling necessary
for the time dependent hardware interfacing.
The I/O subsystem consists of several components:
1. A memory management component that includes buffering, caching, spooling
2. A general device driver interface
3. Drivers for specific hardware devices

VTP-SAV Operating System(22516) Chapter-2


7
Program: Computer Engineering (NBA Accredited)
E-Notes

5. Secondary-Storage Management
Systems have several levels of storage, including primary storage, secondary storage and cache storage.
Instructions and data must be placed in primary storage or cache to be referenced by a running program.
Because main memory is too small to accommodate all data and programs, and its data are lost when power is
lost, the computer system must provide secondary storage to back up main memory. Secondary storage
consists of tapes, disks, and other media designed to hold information that will eventually be accessed in
primary storage (primary, secondary, cache) is ordinarily divided into bytes or words consisting of a fixed
number of bytes. Each location in storage has an address; the set of all addresses available to a program is
called an address space.
The three major activities of an operating system in regard to secondary storage management are:
1. Managing the free space available on the secondary-storage device
2. Allocation of storage space when new files have to be written.
3. Scheduling the requests for memory access.

Q. What are the system tools are used in Linux? Explain two of them in details
User Management: As the administrator, it is your job to create and manage the accounts for all required
users. Linux comes with several tools for user management. User management includes everything from
creating a user to deleting a user on your system.
Following are the Linux command line tools for managing users and groups:
1. useradd.
2. usermod.
3. userdel.
Useradd: Creating New User: To add new users in Linux system we can use useradd command.
Syntax: useradd login_name
Example: useradd xyz

passwd Command: The passwd command is used to set up passwords for users.
Syntax: password user_name
Example: $ passwd vijay
Changing password for vijay:
(current) UNIX password: 123 45
Enter new UNIX password: abc@123
Retype new UNIX password: abc@123
passwd: password updated successfully

Usermod: Modifying Properties of User: The command usermod is used to modify the properties of an
existing user.
Syntax: usermod -c <'newName'> <oldName>
Userdel: Delete a user account: To delete a user account userdel command is used.
Syntax: userdel -r <userName>

Security Policy: Following are the best practices for securing linux os Keep System Updated: Always keep
system updated with latest releases patches, security fixes and kernel when it’s available.
$ yum updates
$yum check-update
Use Secure SSH: Telnet and rlogin protocols uses plain text, not encrypted format which is the security
breaches. SSH is a secure protocol that use encryption technology during communication with server. Never
login directly as root unless necessary. Use “sudo” to execute commands.
$ vi /etc/ssh/sshd_config
$ PermitRootLogin no #disable root login

VTP-SAV Operating System(22516) Chapter-2


8
Program: Computer Engineering (NBA Accredited)
E-Notes

$AllowUsers username # Allow only specific users


$ Protocol 2 #use SSH protocol 2 version
Lock and Unlock Features: They are very useful, instead of removing an account from the system, you can lock
it for an week or a month. To lock a specific user, you can use the follow command.
$ passwd -1 accountname
Turn Off IPv6: If you are not using a IPv6 protocol, then you should disable it because most of the applications
or policies not required IPv6 protocol and currently it doesn’t required on the server. Go to network
configuration file and add followings lines to disable it.
# vi /etc/sysconfig/network
NETWORKING_IPV6=no
IPV6INIT=no
Enables Iptables (Firewall): It is highly recommended to enable Linux firewall to secure unauthorised access of
your servers. Apply rules in iptables to filters incoming, outgoing and forwarding packets. We can specify the
source and destination address to allow and deny in specific udp/tcp port number.
Use Strong Password Policy: Passwords are always a security problem because humans are. People often
cannot be bothered to come up with a lot of different passwords, so they use the same ones in different
places or combinations that are easy to remember, like “password” or “abcde”. Basically, a gift to hackers.
Make it a requirement that any password must contain both upper and lower case, be a mix of numbers,
letters and symbols and you’ll be way safer.
Install Antimalware/Antivirus Software: It is true that there are free anti-malware programs out there, but as
you might expect you get what you pay for. Paid software means better programmers and greater safety. If
your budget won’t stretch that far then consider using ClamAV and Maldet. These are open-source
applications that do a good job of scouring your server for potential threats.
Backup Regularly.

Device Management:
 Device management is the process of managing the implementation, operation and maintenance of a
physical and/or virtual device.
 All Linux device files are located in the /dev directory, which is an integral part of the root (/)
filesystem because these device files must be available to the operating system during the boot
process. The device nodes in the /dev directory provide access to the corresponding kernel devices
 Udev is the device manager for the Linux 2.6 kernel that creates/removes device nodes in the /dev
directory dynamically. udev provides a persistent device naming system through the /dev directory,
making it easier to identify the device.

Performance Monitor: It is really very tough job for every System or Network administrator to monitor and
debug Linux System Performance problems every day.
top Command: Linux top command is a performance monitoring program which is used frequently by many
system administrators to monitor Linux performance and it is available under many Linux/Unix like operating
systems. The top command used to display all the running and active real-time processes in ordered list and
updates it regularly. It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID,
User, Commands and much more. It also shows high memory and CPU utilization of a running processes.
The top command is much useful for system administrator to monitor and take correct action when
required.
$ top

VTP-SAV Operating System(22516) Chapter-2


9
Program: Computer Engineering (NBA Accredited)
E-Notes

vmstat: Linux vmstat command used to display statistics of virtual memory, kernerl threads, disks, system
processes, I/O blocks, interrupts, CPU activity and much more.

Task Scheduler: Crontab files can be used to automate backups, system maintenance and other repetitive
tasks. The syntax is powerful and flexible, so you can have a task run every fifteen minutes or at a specific
minute on a specific day every year.

VTP-SAV Operating System(22516) Chapter-2


Copy protected with Online-PDF-No-Copy.com 10

You might also like