System Structure
System Structure
System Structure
The unix system can be viewed as the set of layers. The lowermost layer
is the hardware layer which is not the part of the unix operating system.
The operating system is called the system kernel or the kernel.
Kernel is the layer where the actual operating system code and
functionality resides. It is in complete isolation from the user programs.
This makes it easier for the programs to be ported onto other system
provided the kernel are same.
If a user program want to perform any task it can do so by talking to the
kernel. The programs interact with the kernel by using the system calls.
The system calls instruct the kernel to do various operations.
Other user programs can be built on top of the lower level programs using
these lower level programs and system calls.
A hierarchal structure.
Consistent treatment of data
Ability to create and delete files
Dynamic growth of files
Peripheral devices are also treated as
files
The file system is organized as a tree. The root node is called “root” and
is denoted by “/”. Every non leaf node in this structure is a directory and
every leaf node is a file/special device file.
The name of the file is given by the path name.
A full path name starts with the root directory i.e. a slash character and
specifies the file that can be found by travestying the tree. Some
examples of paths could be “/etc/passwd”, “/bin/who” and
“/usr/src/programs/test.c”.
The path that starts from the root directory is called the absolute path.
Alternatively we can give path of any file relative to any other directory.
This path will be called relative path.
The files are just stream of bytes it is up-to the program to interpret
these bytes. Directories are also files i.e. a stream of bytes but the
operating system program knows how to interpret them as directories.
Example program could be “ls”
Unix treats devices as if they are files. Every device is treated as special
files and occupy position in the file system. Programs can access devices
using the same syntax as if they were accessing files. Syntax of reading
and writing on devices is more or less same as reading and writing
regular files. Devices are protected in the same way as files i.e. using
access pemissions.
User perspective – Processing environment
One primitive building block available to the shell user is the redirect I/O.
for example
ls
this command list down all the files in the current directory.
ls > output
this command will send this list of files to a file named “output” instead of
the terminal.
The second building block primitive is the PIPE. Pipe allows a stream of
data to be passed from processes. There is one reader process and one
writer process.
ls | more
The system call and library interface represent the border between user
programs and the kernel. System calls look like ordinary function calls in
C programs. Assembly language programs may invoke system calls
directly without a system call library. The libraries are linked with the
programs at compile time.
The set of system calls into those that interact with the file subsystem and
some system calls interact with the process control subsystem. The file
subsystem manages files, allocating file space, administering free space,
controlling access to files, and retrieving data for users.
Processes interact with the file subsystem via a specific set of system
calls, such as open (to open a file for reading or writing), close, read,
write, stat (query the attributes of a file), chown (change the record of who
owns the file), and chmod (change the access permissions of a file).
The file subsystem accesses file data using a buffering mechanism that
regulates data flow between the kernel and secondary storage devices.
The buffering mechanism interacts with block I/O device drivers to initiate
data transfer to and from the kernel.
Device drivers are the kernel modules that control the operator of
peripheral devices. The file subsystem also interacts directly with “raw”
I/O device drivers without the intervention of the buffering mechanism.
Finally, the hardware control is responsible for handling interrupts and for
communicating with the machine. Devices such as disks or terminals may
interrupt the CPU while a process is executing. If so, the kernel may
resume execution of the interrupted process after servicing the interrupt.
Linux Unix
The source code of Linux is freely The source code of Unix is not
available to its users freely available general public