BCA 513 Linux Operating System CIA I Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

BCA 513 Linux Operating System

UNIT I

Open source refers to the computer software or applications where the owners or
copyright holders allow the users or third party to see, use and provide the right to
modify the source code of the product. An Open-source Operating System is the
Operating System in which source code is visible publically and editable. In the case
of an Open Source Operating system, everyone can access and edit the source code.

 Evolution of Linux
In 1991, Linus Torvalds a student at the university of Helsinki, Finland, thought to
have a freely available academic version of Unix started writing its own code. Later
this project became the Linux kernel. He wrote this program specially for his own PC
as he wanted to use Unix 386 Intel computer but couldn't afford it. He did it on
MINIX using GNU C compiler. GNU C compiler is still the main choice to compile
Linux code .He started it just for fun but ended up with such a large project. Firstly he
wanted to name it as 'Freax' but later it became 'Linux'.
He published the Linux kernel under his own license and was restricted to use as
commercially. Linux uses most of its tools from GNU software and are under GNU
copyright. In 1992, he released the kernel under GNU General Public License.

SYSTEM STRUCTURE

Figure below depicts the high-level architecture of the Linux system. The hardware at
the center of the diagram provides the operating system with basic services. The
operating system interacts directly with the hardware, providing common services to
programs and insulating them from hardware idiosyncrasies. Viewing the system as a
set of layers, the operating commonly called the system kernel, or just the kernel,
emphasizing its
isolation from user programs. Because programs are independent of the underlying
hardware, it is easy to move them between UNIX systems running on different
hardware if the programs do not make assumptions about the underlying hardware.
Programs such as the shell and editors (ed and vi) shown in the outer layers interact
with the kernel by invoking a well defined set of system calls. The system calls
instruct the kernel to do various operations for the calling program and
exchange data between the kernel and the program. Several programs shown in the
figure are in standard system configurations and are known as commands, but private
user programs may also exist in this layer as indicated by the program whose name is
a.out, the standard name for executable files produced by the C compiler. Other
application programs can build on top of lower-level programs,hence the existence of
the outermost layer in the figure.

ASSUMPTIONS ABOUT HARDWARE


The execution of user processes on UNIX systems is divided into two levels: user and
kernel. When a process executes a system call, the execution mode of the process
changes from user mode to kernel mode: the operating system executes
and attempts to service the user request, returning an error code if it fails.
The difference between the two modes is :
• Processes in user mode can access their own instructions and data but not kernel
instructions and data (or those of other processes). Processes in kernel mode,however,
can access kernel and user addresses.
ARCHITECTURE OF THE UNIX OPERATING SYSTEM

Figure gives a block diagram of the kernel, showing various modules and their relationships
to each other. In particular, it shows the file subsystem on the left and the process control
subsystem on the right, the two major components of the kernel. The diagram serves as a
useful logical view of the kernel.
Figure shows three levels: user, kernel, and hardware. 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, and libraries map these function calls to the primitives needed
to enter the operating system.

BLOCK DIAGRAM OF THE SYSTEM KERNEL


The figure partitions the set of system calls into those that interact with the file
subsystem and those that 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 operation of
peripheral devices. Block I/O devices are random access storage devices alternatively,
their device drivers make them appear to be random access storage
devices to the rest of the system. The file subsystem also interacts directly with "raw"
I/O device drivers without the intervention of buffering mechanism. Raw devices,
sometimes called character devices, include all devices that are not block devices.
The process control subsystem is responsible for process synchronization ,interprocess
communication, memory management, and process scheduling. The file subsystem
and the process control subsystem interact when loading a file into memory for
execution,
Some of the system calls for controlling processes are fork (create a new process), exec
(overlay the image of a program onto the running process), exit (finish executing a
process), wait (synchronize process execution with the exit of a
previously forked process).
The memory management module controls the allocation of memory. If at any time
the system does not have enough physical memory for all processes, the kernel moves
them between main memory and secondary memory so that all processes get a fair
chance to execute.
The scheduler module allocates the CPU to processes. It schedules them to run in turn
until they voluntarily relinquish the CPU while awaiting a resource or until the kernel
preempts them when their recent run time exceeds a time quantum. The
scheduler then chooses the highest priority eligible process to run; the original process
will run again when it is the highest priority eligible process available.
There are several forms of interprocess communication, ranging from asynchronous
signaling of events to synchronous transmission of messages between processes.
Finally, the hardware control is responsible for handling interrupts and for
communicating with the machine.

An Overview of the File Subsystem

The internal representation of a file is given by an inode, which contains a description


of the disk layout of the file data and other information such as the file owner, access
permissions, and access times. The term inode is a contraction of the
term index node Every file has one inode, but it may have several names, all of which
map into the inode. Each name is called a link.
An inode is a data structure. It defines a file or a directory on the file system and is
stored in the directory entry. Inodes point to blocks that make up a file. The inode
contains all the administrative data needed to read a file. Every file’s metadata is
stored in inodes in a table structure.Every inode in the Linux structure has a unique
number identified with it. It is also called the index number and has the following
attributes:
 Size
 Owner
 Date/time
 Permissions and access control
 Location on the disk
 File types
 Number of links
 Additional metadata about the file
When a process refers to a file by name, the kernel parses the file name one
component at a time, checks that the process has permission to search the directories
in the path, and eventually retrieves the inode for the file.

File Descriptors, File Table, and inode Table

The kernel contains two other data structures, the file table and the user file descriptor
table. The file table is a global kernel structure, but the user file descriptor table is
allocated per process. When a process opens or creats a file, the
kernel allocates an entry from each table, corresponding to the file's mode. Entries in
the three structures user file descriptor table, file table, and inode table — maintain the
state of the file and the user's access to it. The file table keeps track
of the byte offset in the file where the user's next read or write will start, and the
access rights allowed to the opening process. The user file descriptor table identifies
all open files for a process. Figure shows the tables and their
relationship to each other. The kernel returns a file descriptor for the open and creat
system calls, which is an index into the user file descriptor table. When executing
read and write system calls, the kernel uses the file descriptor to access
the user file descriptor table, follows pointers to the file table and inode table entries,
and, from the inode, finds the data in the file.
Partitioning a disk into several file systems makes it easier for administrators to
manage the data stored there.

Figure File System Layout


A file system has the following structure :
• The boot block occupies the beginning of a file system, typically the first sector, and
may contain the bootstrap code that is read into the machine to boot, or initialize, the
operating system. Although only one boot block is needed to boot
the system, every file system has a (possibly empty) boot block.
• The super block describes the state of a file system — how large it is, how many
files it can store, where to find free space on the file system, and other information.
• The inode list is a list of modes that follows the super block in the file system.
Administrators specify the size of the inode list when configuring a file system.
• The data blocks start at the end of the mode list and contain file data and
administrative data. An allocated data block can belong to one and only one file in the
file system.

Directory Structure
Linux uses a hierarchical file system structure, much like an upside-down tree, with
root (/) at the base of the file system and all other directories spreading from there.
A Linux filesystem is a collection of files and directories that has the following
properties −
 It has a root directory (/) that contains other files and directories.
 Each file or directory is uniquely identified by its name, the directory in which
it resides, and a unique identifier, typically called an inode.
The directories have specific purposes and generally hold the same types of
information for easily locating files. Following are the directories that exists −

Sr.No Directory & Description


.

1 /
This is the root directory which should contain only the directories needed at the
top level of the file structure.

2 /bin
This is where the executable files are located. These files are available to all
users

3 /dev
These are device drivers

4 /etc
Supervisor directory commands, configuration files, disk configuration files, valid
user lists, groups, ethernet, hosts, where to send critical messages

5 /lib
Contains shared library files and sometimes other kernel-related files

6 /boot
Contains files for booting the system

7 /home
Contains the home directory for users and other accounts

8 /mnt
Used to mount other temporary file systems, such as cdrom and floppy for
the CD-ROM drive and floppy diskette drive, respectively

9 /proc
Contains all processes marked as a file by process number or other information
that is dynamic to the system

10 /tmp
Holds temporary files used between system boots

11 /usr
Used for miscellaneous purposes, and can be used by many users. Includes
administrative commands, shared files, library files, and others

12 /var
Typically contains variable-length files such as log and print files and any other
type of file that may contain a variable amount of data

13 /sbin
Contains binary (executable) files, usually for system administration. For
example, fdisk and ifconfig utlities

14 /kernel
Contains kernel files

You might also like