14 Slices
Medium 9789381159057

Ch-4

Anoop Chaturvedi ; B.L. Rai Laxmi Publications PDF

Chapter

4

BUFFER CACHE

When a process want to access data from a file, the Kernel brings the data into main memory where the process can examine it alter it and request that the data be saved in the file system again. The super block of a file system describes the free space available on the file system. The

Kernel reads the super block into memory to access its data and writes it back to the file system when it wishes to save its data. Similarly the inode describes the layout of file. The Kernel reads an inode into memory when it want to update the file layout.

The Kernel could read and write directly to and from the disk for all file system access, but system response time and throught put would be poor because of the slow disk transfer rate. The

Kernel therefore minimize the frequency of disk access by keeping a pool of internal data buffers, called the buffer cache which contains the data inrecently used disk blocks.

The position of buffer cache module in Kernel architecture between the file subsystem and

See All Chapters
Medium 9789381159057

Ch-6

Anoop Chaturvedi ; B.L. Rai Laxmi Publications PDF

42

U NIX

AND

S HELL P ROGRAMMING

Chapter

INODE A SSIGNMENT

TO A

6

NEW F ILE

The file system contains a linear list of inodes. An inode is free if its type field is zero. When a process needs a new inode, the Kernel could theoretically search the inode list for a free node.

However, such a search would be expensive, requiring atleast one read operation for every inode.

To improve performance, the file system super block contains an array to cache the numbers of free inodes in the file system.

For assigning new inodes. The Kernel first verifies that no other processes have locked access to the super block free inode list. If the list of inode numbers in the super block is not empty the

Kernel assigns the next inode number, allocates a free incore inode for the newly assigned disk inode copies the disk inode to the incore copy initilizes the fields in the inode and returns the locked inode. It updates the disk inode to indicate that the inode is now in use. A non zero file type field indicates that the disk inode is assigned.

See All Chapters
Medium 9789381159057

Ch-11

Anoop Chaturvedi ; B.L. Rai Laxmi Publications PDF

SOCKETS

97

11

Chapter

SOCKETS

Furthermore, the methods may not allow processes to communicate with other processes on the same m/c because they assume existence of a server process that sleeps in a driver open or read system call. To provide common methods for IPC and to allow use of sophisticated n/w protocols, the BSD system provides a mechanism known as sockets.

Client Process

Server Process

Socket layer

Protocol layer

Socket layer

TCP

Protocol layer

IP

Device layer

TCP

IP

Device layer

Ethernet

Driver

Ethernet

Driver

N/W

Fig. 11.1 Sockets model

The Kernel structure consists of three parts:

(i)

Socket Layer—Provide the interface b/w the system calls and the lower layers.

(ii)

Protocol Layer—Contains the protocol modules used for communication (e.g., TCP/IP).

(iii)

Device Layer—Contains the device driver that control the n/w devices.

Layer combinations of protocols and drivers are specified when configuring the system.

Process communicate using the client server model; a server process listens to a socket one end point of a two way communication path, and client process communicate to the server process cover another socket, the other end point of communications path which may be on another m/c. The Kernel maintains internal connections and routes data from client to server.

See All Chapters
Medium 9789381159057

Ch-10

Anoop Chaturvedi ; B.L. Rai Laxmi Publications PDF

90

U NIX

AND

S HELL P ROGRAMMING

Chapter

10

INTER -PROCESS COMMUNICATION

IPC mechanism allow arbitrary process to exchange data and synchronize execution.

We have already considered several forms of interprocess communication, such as pipes, named pipes and signals. Pipes suffer from the drawback that they are known only to processes which are descendants of the process that invoke the pipe system call: unrelated process cannot communicate via pipes. Although named pipe allow unrelated process to communicate, they cannot generally be used across a network nor do they readily lend themselves to setting up multiple communications paths for different sets of communicating process: its impossible to multiplex a named pipe to provide private channels for pairs of communicating process. Arbitrary process can also communicate by sending signals via the kill system call, but the message consist only of the signal number.

10.1 PROCESS TRACING

One process traces and controls the execution of another process. Tracing processes, useful for debugging. A debugger process such as sdb, spawns a process to be traced and controls its execution with the ptrace system call, setting and clearing break points, and reading and writing data in its virtual address space.

See All Chapters
Medium 9789381159057

Ch-8

Anoop Chaturvedi ; B.L. Rai Laxmi Publications PDF

70

U NIX

AND

S HELL P ROGRAMMING

Chapter

STRUCTURE

OF A

8

P ROCESS

The Kernel contains a process table with an entry that describes the state of every active process in the system. The u-area contains additional information that controls the operation of a process. The process table entry and the u-area are part of the context of a process. The aspect of the process context that most visibly distinguishes it from the context of another process is of course, the contents of its address space.

8.1 PROCESS STATES AND TRANSITIONS

The following list contains the complete set of process states.

(i)

The process is executing in user mode.

(ii)

The process is executing in Kernel mode.

(iii)

The process is not executing but is ready to run as soon as the Kernel schedules it.

(iv)

The process is sleeping and resides in main memory.

(v)

The process is ready to run, but the swapper (schedule process O) must swap the process into main memory before the Kernel can schedule it to execute.

(vi)

The process is sleeping and the swapper has swapped the process to secondary storage to make room for other processes in main memory.

See All Chapters

See All Slices