Osy Chapter 02
Osy Chapter 02
OPERATING SYSTEM
Services in Operating System:
Program Execution
File Management
Error Handling
Resource Management
Security
Accounting
System Calls:
A system call is the programmatic way in which a computer program
requests a service from the kernel of the operating system it is executed on.
OS provides a variety of system calls to control the process.All the processors
provide instructions that can be used as a system calls.
They act as a bridge between user-space and kernel-space, enabling user
programs to access operating system services and resources in a controlled
and secure manner.
It provides the interface between a running program and the operating
system.
A number of services are requested by the program, and the OS
responds by launching a number of systems calls to fulfill the request.
1. Process Control:
If we create a new job or process we should able to control its execution
Process control system calls are a category of system calls that allow user-
level processes to manage and control processes within an operating system.
These system calls provide essential functionalities for process creation,
termination, and process status management.
These system calls enable user-level processes and applications to control
the execution of processes, and perform other process-related operations.
Examples of process related system call:
I. End,Abort
II. Load,Execute
III. Create process, Terminate process
IV. Suspend process,Resume process
V. Get process attribute, Set process attribute
VI. Wait event,Signal event
2. File management:
File management system calls in an operating system provide a way for
processes and applications to interact with files and directories.
System allows us to create and delete files. For create and delete operation
system call requires the name of the file and other attributes of the file.
File attributes include file type, file size, protection codes, accounting
information and so on. Systems access these attributes for performing
operations on file and directories.
Once the file is created, we can open it and use it. System also allows
performing reading, writing or repositioning operations on file.
i. create file delete file
ii. open, close
iii. read, write, reposition
iv. get file attributes, set device attributes
v. logically attach or detach devices
3.Device Management:
Device management system calls in an operating system provide a way for
processes and applications to interact with hardware devices, such as disks,
printers, network interfaces, and other peripherals.
When a process is in running state, it requires several resources to execute.
These resources include main memory, disk drives, files and so on.
If the resource is available, it is assigned to the process. Once the resource is
allocated to the process, process can read, write and reposition the device.
i. request device, release device
ii. read, write, reposition
iii. get device attributes, set device attributes
iv. logically attach or detach devices
4.Information Maintenance:
Transferring information between the user program and the operating
system requires system call.
System information includes displaying current date and time, the number
of current user, the version number of the operating system, the amount of
free memory or disk space and so on.
Operating system keeps information about all its processes that can be
accessed with system calls such as get process attributes and set process
attributes.
i. get time or date, set time or date
ii. get system data, set system data
iii. get process, file, or devices attributes
iv. set process, file, or devices attributes
Communication:
Processes in the system, communicate with each other. Communication is
done by using two models: message passing and shared memory.
In message passing the communicating processes exchange messages with
one another to transfer information. It uses a common mailbox to pass
messages between processes
Shared memory is a mechanism where two or more processes can directly
access a common region of memory. This memory region is allocated by the
operating system and can be used for reading and writing data. For
transferring messages, sender process connects itself to receiving process by
specifying receiving process name or identity. Once the communication is
over system close the connection between communicating processes.
I. Establish a connection
II. Send,receive messages
III. Terminate a connection
Operating System Components:
1. Process Management:
A program is a set of instructions. When CPU is allocated to a program, it can
start its execution. A program in execution is a process.
A word processing program run by a user on a PC is a process. A process
needs various system resources including CPU time, memory, files and I/O
devices to complete the job execution. These resources can be given to the
process when it is created or allocated to it while it is running.
The operating system responsible for the following activities in connection
with process management:
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.
2. Main-Memory Management:
Main memory is a large array of words or bytes, ranging in size from
hundreds of thousands to billions. Each word or byte has its own address.
Main memory is a repository of quickly accessible data shared by the CPU
and I/O devices. The central processor reads instructions from main
memory during the instruction fetch cycle and both reads and writes data
from main memory during the data fetch cycle. The main memory is
generally the only large storage device that the CPU is able to address and
access directly.
The operating system responsible for the following activities in connection
with main memory s management:
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 collection 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 operating system responsible for the following activities in connection
with file management:
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. Secondary-Storage Management:
The computer system provides secondary storage to back up main memory.
Secondary storage is required because main memory is too small to
accommodate all data and programs, and the data that it holds is lost when
power is lost. Most of the programs including compilers, assemblers, word
processors, editors, and formatters are stored on a disk until loaded into
memory. Secondary storage consists of tapes drives, disk drives, and other
media.
The operating system is responsible for the following activities in connection
with disk management:
1. Free space management
2. Storage allocation
3. Disk scheduling.
User Management:
As the administrator it is your job to create and manage the accounts for all
required users. To facilitate this, linux comes with several tools for user
management.
It 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:
Useradd
Usermod
Userdel
Root:The root is the superuser, and haqve all the powers for creating a
user,deleting a user.
Security Policy:
Keep system updated:Always keep the system with latest releases
patches,security fixes and kernel when its available.
Deactivate network port: With the help of ‘netstat’ networking command you
can view all openports. Use ‘chckconfig’ command to disable all unwanted
network services.
Lock and unlock features: Instead of removing an account from the system
you can lock it for an week or a month.
Turn of IPV6: If you are not using iPV6 protocol then you should disable it
because most of the application does not require IPV6 protocol.
Enables firewall: It is higly recommended to enable linux firewall to secure
unauthorised access of your system.
Use strong password policy
Install Antimalware/Antivirus software
Device Management:
Device files are employed to provide the operating system and users an
interface to the devices that they represent.
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.
Data is passed from an application or the operating system to the device file
which then passes it to the device driver which then sends it to the physical
device.
Task Scheduler:
"Task Scheduler" is a combination of several tools and services that allow
users to schedule and automate tasks or jobs. These tools are typically used
through the command line or configuration files.
One of the most commonly used task scheduling tools in Linux is the cron
system.
cron: cron is a time-based job scheduler in Linux and other Unix-like
operating systems. It allows users to schedule tasks (known as cron jobs) to
run at specified intervals or times.
These tasks can be scripts, commands, or any executable file. The cron jobs
are defined in the crontab (cron table) files.