LC 1
LC 1
Programming
Teachers: Nicolas Magaud, Konul Aliyeva
CM01: Introduction / OS Programming
Synopsis
●
use the main system calls properly, thus
enabling communication between a program
and the operating system;
●
write programs handling system objects such
as processes, files, directories, pipes and
signals;
●
optimize the use of system resources;
●
make programs interact with one another.
Requirements
●
write programs using C features (such as
dynamic data structures, pointers, binary
operators, etc.);
●
translate algorithms into actual C programs;
●
read and write shell script
Operating System
●
Keeps tracks of primary memory, i.e., what part
of it are in use by whom, what part are not in
use.
●
In multiprogramming, the OS decides which
process will get memory when and how much.
●
Allocates the memory when a process requests
it to do so.
●
De-allocates the memory when a process no
longer needs it or has been terminated.
Processor Management
●
Keeps tracks of processor and status of
process. The program responsible for this task
is known as traffic controller.
●
Allocates the processor (CPU) to a process.
●
De-allocates processor when a process is no
longer required.
Device Management
●
Keeps tracks of all devices. Program
responsible for this task is known as the I/O
controller.
●
Decides which process gets the device when
and for how much time.
●
Allocates the device in the efficient way.
●
De-allocates devices.
File Management
●
Keeps track of information, location, uses,
status etc. The collective facilities are often
known as file system.
●
Decides who gets the resources.
●
Allocates the resources.
●
De-allocates the resources.
Other Important Activities
●
Security − By means of password and similar other techniques, it
prevents unauthorized access to programs and data.
●
Control over system performance − Recording delays between
request for a service and response from the system.
●
Job accounting − Keeping track of time and resources used by
various jobs and users.
●
Error detecting aids − Production of dumps, traces, error messages,
and other debugging and error detecting aids.
●
Coordination between other softwares and users − Coordination and
assignment of compilers, interpreters, assemblers and other software
to the various users of the computer systems.
Operating System Services
●
Program execution
●
I/O operations
●
File System manipulation
●
Communication
●
Error Detection
●
Resource Allocation
●
Protection
Program execution
●
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 Operation
●
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
●
Program needs to read a file or write a file.
●
The operating system gives the permission to the program for
operation on file.
●
Permission varies from read-only, read-write, denied and so on.
●
Operating System provides an interface to the user to
create/delete files.
●
Operating System provides an interface to the user to
create/delete directories.
●
Operating System provides an interface to create the backup of
file system.
Communication
●
Two processes often require data to be
transferred between them
●
Both the processes can be on one computer or
on different computers, but are connected
through a computer network.
●
Communication may be implemented by two
methods, either by Shared Memory or by
Message Passing.
Error handling
●
The OS constantly checks for possible errors.
●
The OS takes an appropriate action to ensure
correct and consistent computing.
Resource Management
●
The OS manages all kinds of resources using
schedulers.
●
CPU scheduling algorithms are used for better
utilization of CPU.
Protection
●
The OS ensures that all access to system
resources is controlled.
●
The OS ensures that external I/O devices are
protected from invalid access attempts.
●
The OS provides authentication features for
each user by means of passwords.
Operating System – Processes
A process is defined as an entity which
represents the basic unit of work to be
implemented in the system.
Process Life Cycle
Operating System Scheduling Algorithms
●
First-Come, First-Served (FCFS) Scheduling
●
Shortest-Job-Next (SJN) Scheduling
●
Priority Scheduling
●
Shortest Remaining Time
●
Round Robin(RR) Scheduling
●
Multiple-Level Queues Scheduling
●
Etc.
POSIX Standard-Portable Operating System Interface
●
Functions which do not call any system call.
The string manipulation functions like strlen()
etc fall under this category.
●
Functions that make a system call.
The fopen() function which is a standard library
function but internally uses the open() sytem
call.
Interaction Between Components
fopen() vs open()