Sie sind auf Seite 1von 18

C.S.

I INSTITUTE OF TECHNOLOGY

Department of COMPUTER APPLICATIONS

MC9292 UNIX Internals

Question Bank

2 Marks Questions
1. What are the different parts of UNIX system?
i. Programs and services that have made the UNIX system environment.
ii. Operating system that supports those programs and services.
2. What are the goals of Multics system?
To provide simultaneous access to a large community of users, to supply
ample computation power and data storage, and to allow users to share their data
easily, if desired.
3. What are the reasons for popularity of UNIX operating system?
i. The system is written in high level language, make it easy to read, understand,
change, and move to other machines.
ii. It has a simple user interface that has the power to provide the services that
users want.
iii. It provides primitives that permit complex programs to be built from simpler
programs.
iv. It uses a hierarchical file system, consistent format for files, byte stream,
making application programs easier to write.
v. It provide simple and consistent interface to peripheral devices.
vi. It is a multi user multi process system, it hides the machine architecture from
user.
4. What is the purpose of system calls?
It instructs the kernel to do various operations for the calling program and
exchange data between the kernel and the program.
5. Write down the characteristics of UNIX file system?
A hierarchical structure.
Consistent treatment of file data.
The ability to create and delete files.
Dynamic growth of files.
The protection of file data.
The treatment of peripheral devices as files
6. Define path name and component.
A path name is a sequence of component names separated by slash characters; a
component is a sequence of characters that designates a file name that is uniquely
contained in the previous component.
7. What do you mean by access permissions?
Access permissions are set of bits associated with each file. Access permissions
can be set independently to control read, write, and execute permission for three classes
of users: the file owner, a file group and every one else.
8. Define program and process.
A program is an executable file, and a process is an instance of the program in
execution.
9. What is the purpose of building block primitives?
Building block primitives enable users to write small, modular programs that
can be used as building blocks to build complex programs. Example for primitives is
capability to redirect I/O.
10. What are the services provided by the kernel?
i. Controlling the execution of processes by allowing their creation, termination or
suspension and communication.
ii. Scheduling processes for execution on the CPU.
iii. Allocating main memory for an executing process.
iv. Allocating secondary memory for efficient storage and retrieval of user data.
v. Allowing processes controlled access to peripheral devices.
11. What is the purpose of memory management?
Memory management module controls the allocation of memory. If at any time
the system does not have enough memory for all processes the kernel moves them
between main memory and secondary memory so that all processes get a fair chance to
execute.
12. What is the job done by scheduler?
The scheduler module allocates the CPU to process. It schedules them to run in
turn until they voluntarily relinquish the CPU while awaiting a resource until the kernel
preempts them when their recent run time exceeds a time quantum. The scheduler then
chooses a highest priority eligible process to run.
13. What do you mean by swapping?
UNIX system transferred entire processes between primary memory and swap
device, but did not transfer parts of a process independently, except for a shared text.
Such a memory management policy is called swapping
14. List down the types of file
Regular file, Directory file, FIFO files, Character special file, Block special file,
socket file, symbolic file.
15. What are the different type of commands supported by shell?
i) A command can be an executable file that contains object code produced by
compilation of source code.
ii) A command can be executable file that contains a sequence of shell command lines.
iii) A command can be an internal shell command
16. Define shell programming.
It a command interpreter program that users typically execute after logging into
system. The shell interprets the first word of command line as a command name. For
many commands the shell forks and the child process execs a command associated with
the name.
17. What are the execution modes of the user process? Define that.
There are two levels of user process ie, user and kernel. When a process executes
a system call the execution mode of the process changes from user mode to kernel mode.
18. What is the difference between user mode and kernel mode?
Processes in user mode can access their own instructions and data but not kernel
instructions and data. Processes in kernel mode can access kernel and user addresses.
Some machine instructions are only privileged to kernel mode.
19. Define interrupts.
Interrupts are caused by events that are external to process. Interrupts are
considered to happen between the execution of two instructions, and the system continues
with the next instruction after servicing the interrupt.
20. Define exception.
Exception refers to unexpected events caused by a process such as addressing
illegal memory, executing privileged instructions, dividing by zero and so on. Exception
happen in the middle of the execution of an instruction and the system attempts to restart
the instruction after handling the exception.
21. Write some sample processor execution levels?
Machine errors
Clock
Disk
Network devices
Terminals
Software interrupts
22. What are the different communications supported by UNIX?
Inter process communication and network communication
23. What do you mean by Inter process communication?
UNIX operating system supports multiple processes simultaneously. The
communications between these processes are referred as Inter process communication.
24. What are the different inter process communication methods supported by UNIX V
Message Queues
Named and unnamed pipes
Share memory
Semaphore
25. What is the purpose of file sub system?
The file sub system accesses file data using a buffering mechanism that regulates
data flow between the kernel and secondary storage device.
26. What are the central concepts of UNIX system?
The entities files and processes are referred as central concepts of UNIX.
27. What are the different levels of operation in UNIX kernel?
User Level: The user programs and the libraries are available here.
Kernel level: This is the heart of UNIX operating system. All the
operations related to file system, process control sub system,
hardware control, and device drivers are available in this level.
Hardware level: The physical components of the system are available here.
27. What is the purpose of file sub system?
The file sub system accesses file data using a buffering mechanism that regulates
data flow between the kernel and secondary storage device.
28. What is the purpose of memory management?
Memory management module controls the allocation of memory. If at
any time the system does not have enough memory for all processes the kernel moves
them between main memory and secondary memory so that all processes get a fair
chance to execute.
29. Write down the purpose of buffering mechanism?
Buffering mechanism interacts with block I/O device drivers to initiate
data transfer to and from the kernel.
30. What is the job done by device drivers and block I/O devices?
Device drivers are the kernel modules that control the operation of peripheral
devices. Block I/O devices are random access storage devices
31. What is the purpose of process control subsystem?
The process control subsystem is responsible for process synchronization, inter
process communications, memory management and process scheduling. The file
subsystem and process control subsystem interact when loading a file into memory
for execution. The process control subsystem reads executable files into memory
before executing them.
32. Write down the system calls useful for control the processes?
fork: To create a new process
exec: overlay the image of the program into the running process
exit: to terminate a process
wait: to introduce synchronization between the process.
brk: control the size of the memory allocated to a process.
signal: control process response to extraordinary events.
33. What are the data structures used for file processing?
File table: It is a global data structure
User file descriptor table: It is allocated per process
When a process opens or creats a file the kernel allocates an entry from
each table corresponds to the file inode.
Inode: Internal representation of file is given by an inode, which contains a
description of the disk layout of the file data and other information
related to permission, access time, owner etc.
34. Write about file system layout
Boot block : This occupies the beginning of a file system, typically first sector,
and may contain the bootstrap code
Super block: describes the state of the file system.
Inode list : A list of inodes that follows the super block in the file system.
Data blocks: Contain file data and administrative data.
35. Define process.
A process is the execution of a program and consists of a pattern of bytes that the
CPU interprets as machine instructions, data, and stack.
36. What are the contents of executable file?
i. Set of headers that describes the attributes of the file.
ii. A program text.
iii. A machine language representation of data that has initial values when the program
starts execution, and an indication of how much space the kernel should
allocate for uninitialized data.
iv. Symbol table information
37. List down the fields in process table.
State field
Identifiers indicating the user who owns the process
An event descriptor set when a process is suspende
36. What are the information available in inode?
A descriptor of the disk layout of the file data and other information such as
the file owner, file access permissions and access times.
37. Define the components of file system.
a.Boot block: This block occupies the beginning of the file system, typically the
first sector, and may contain the bootstrap code.
b.Super block: describes the state of file system- how large it is, how many files
it can store, where to find free space on the file system and other information.
c.Inode list: List of inodes.
d.Data block: This block contains file data and administrative data.
38. Define process.
A process is the execution of the program and consists of the pattern of bytes
that the CPU interrupts as machine instructions, data, and stack.
39. What are the components of executable file?
a. Set of a headers that describe the attributes of file.
b. The program text
c. A machine language representation of data that has initial values when the
program starts execution and an indication of how much space the kernel should
allocate for uninitiallized data
d. Other sections such as symbol table information.
40. What is the content of stack frame?
Stack frame contains the parameters to a function, its local variables, and the
data necessary to recover the previous stack frame, including the value of program
counter and stack pointer at the time of the program call.
41. What are the contents of user stack and kernel stack?
The user stack contains the arguments, local variables, and other data for
functions executing in user mode. The kernel stack contains the stack frames for
functions executing in kernel mode.
42. What are the important fields in u area?
Pointer to process table slot of the currently executing process
Parameters of the current system call return values and error codes
Internal I/O parameters
Current directory and current root
Process and file size limits
43. What are the factors affect the state of the process?
Text of the process, the values of its global user variables and data structures, the
values of machine registers it uses, the values stored in its process table slot and u_area
and the contents of its user and kernel stacks.
44. Define context switch.
When the kernel decides to execute another process the kernel saves the necessary
information so that it can later switch back to the first process and resume its execution.
45. Define process state and list down the different basic process states.
The lifetime of a process can be divided into a set of states, each with certain
characteristics that describe the process. The basic process states are
i. The process is currently executing in user mode.
i. The process is currently executing in kernel mode .
ii. The process is not executing, but it is ready to run.
iii. The process is sleeping.
46. Define state transition diagram.
It is a directed graph whose nodes represent the states a process can enter and
whose edges represent the events that cause a process to move from one state to another.
State transitions are legal between two states if there exist an edge from the first state to
the second.
47. Describe the contents in buffer cache.
The buffer consists of two parts: a memory array that contains data from the disk
and a buffer header that identifies the buffer. The data in buffer corresponds to the data in
a logical disk block and kernel identifies the buffer contents by examining identifier
fields in the buffer header.
48. What is the information available in buffer header?
The buffer header contains a device number field and block number fields that
specify the file system and block number of the data on disk and uniquely identify the
buffer. It also contains a pointer to a data array, status field.
49. How will you identify the status of the buffer?
1. The buffer is currently locked.
2. The buffer contains valid data.
3. The kernel must write buffer contents to disk before reassigning the buffer
4. The kernel is currently reading or writing the contents of the buffer to disk.
5. A process is currently waiting for the buffer to become free.
50. What are the different scenarios to allocate a buffer for a disk block
i. The kernel finds the block on its hash queue and its buffer cache.
ii. The kernel cannot find the block o the hash queue, so it allocates a buffer from the
free list.
iii. The kernel cannot find the block o the hash queue and in attempting to allocate
buffer from the free list, find a buffer on a free list that has been marked delayed
write. The kernel must write the delayed write buffer to disk and allocate
another buffer.
iv. The kernel cannot find the block o the hash queue, and the free list of buffers is
empty.
v. The kernel finds the block on the hash queue but its buffer is currently busy.
51. Write down the difference between named and unnamed pipes
A major difference between theses IPC mechanism is the related processes are
allowed to communicate using unnamed pipes but the unrelated processes are also
communicate in named pipes.
52. What is the purpose of debugger process?
A debugger process 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.
53. What are the jobs done by process tracing?
i. Synchronization of the debugger process and the traced process.
ii. Controlling the execution of traced process.
54. Write down the structure of debugging process.
if ((pid = fork() ) = = 0)
{ /* child traced process */
ptrace(0,0,0,0);
exec(name of traced process here);
}
/* debugger process continues here */
for ( ; ;)
{
wait((int *) 0);
read(input for tracing instructions);
ptrace(cmd,pid,);
if (quitting trace)
break;
}
55. List down the drawbacks of ptrace function.
i. The kernel must do four context switches to transfer a word of data between a
debugger and a traced process.
ii. A debugger can only trace child processes. If the traced child forks the debugger
has no control over the grandchild.
iii. A debugger cannot trace processes that is already executing if the debugged
process had not called ptrace to let the kernel know that it consents to be traced.
iv. It is impossible to trace setuid function, because the users could violate security
by writing their address space via ptrace and doing illegal operations.
56. What are the advantages of ptrace function introduces by Killian?
i. It is faster than orinary ptrace function.
ii. A debugger can trace arbitrary processes.
iii. The traced process does not have to make prior arrangement to allow tracing.
57. What the Inter process communication mechanisms available in System V?
i. Messages allow processes to send formatted data streams to arbitrary processes.
ii. Shared memory allows processes to share parts of their virtual address space.
iii. Semaphores allow processes to synchronize execution.
58. List down the common properties of system V IPC.
i. Each mechanism contains a table whose entries describe all instances of the
mechanism.
ii. Each entry contains a numeric key.
iii. Each mechanism contains get system call to create a new entry or to retrieve
an existing entry.
iv. The kernel uses the following formula to find the index into the table
Index = descriptor modulo (number of entries in table)
v. Each IPC entry has a permission structure that includes the user ID and group
ID, read_write_execute permissions for owner, group and others.
vi. Each entry contains other status information like time of last access or update
etc.
vii. Each mechanism contains a control system call to query status of an entry, to set
status information or to remove the entry from the system.
59. What are the system calls related to message queues?
i. msgget returns a message descriptor that designates a message queue for use in
other system calls.
ii. msgctl has options to set and return parameters associated with a message
descriptor and an option to remove descriptors.
iii. msgsnd sends a message
iv. msgrcv receives a message.
60. What are the different process states in UNIX?
The possible process states are
User running
Kernel running
Ready to run in memory
Asleep in memory
Ready to run, but it is swapped process
Sleep, but it is swapped
Preempted
Created
Zombie state
61. What are the entries in process table?
State field, user identifiers, process identifiers, scheduling parameters, signal
field, timer fields
62. What are the I/O parameters in U area?
I/O parameters in U area are
Mode - indicates read and write
Count count of bytes to read and write
Offset byte offset in file
Address target address to copy data in user or kernel memory
Flag indicate a if address is in user or kernel memory
63. Write down the entries in u area.
A pointer to a process table, Real and effective user Ids, array for signals,
timer fields, control terminal field, error field, return value field, I/O parameters,
current directory, current root, user file descriptor, limit fields, permission modes
field.
64. Define region.
System V divides the virtual address space of a process into logical divisions
called regions. A region is a continuous area of the virtual address space of a process
that can be treated as a distinct object to be shared or protected.
65. What are the components of register context?
The register context consists of the following components
Program counter
Processor status register
Stack pointer
General purpose registers
66. What are the components of system level context?
The system level context consists of the following components
Process table entry of a process
U area of a process
Pregion entries
Kernel stack
Dynamic part of system level context
67. What are the operations during interrupt handling?
The kernel handles the interrupt with the following sequence of operations
It saves the current register context and creates a new context layer.
It determine the source of interrupt, type of interrupt and unit number
Kernel invoke the interrupt handler
Restore its previous context layer
68. Write down the steps for context switch.
Set of steps used for context switch are
i) decide whether to do a context switch and whether a context switch is
permissible now.
ii) Save the context of old process
iii) Find the best process to schedule for execution
iv) Restore its context
69. Write down the contents of region table entry.
The contents in region table entries are
A pointer to inode of the file
Region type
Size of region
Location of region in physical memory


Status of region locked, demand, loaded into memory or valid in
memory
Reference count
70. What are the operations done by the kernel during fork function?
The operations during fork function are
Its allocate a slot in process table for the new process
It assign a unique ID number
It makes the logical copy of the context of the parent process
It increments the file and inode table counters for files associated with the
process
It returns the Id of a child to parent and 0 in child process
71. Write down the process-scheduling algorithm.
Algorithm for process scheduling
Input and output are none
{
while(no process picked to execute)
{
for(every process on run queue)
pick highest priority process that is loaded in memory;
if (no process eligible to execute)
idle the machine;
}
remove chosen process from run queue;
switch context to that of chosen process, resume its execution.
}
72. What are the classes of process priorities?
User priorities and kernel priorities
73. What are the different process priority levels in kernel priorities?
Swapper, waiting for disk I/O, waiting for buffer, waiting for inode, waiting
for tty input, waiting for tty output, waiting for child exit
74. Write down the principle of fair share scheduler.
This scheduler divides the user community into a set of fair share groups. The
member of each group are subjects to the constraints of the regular process scheduler
relative to other processes in the group. The system allocates its CPU time
proportionally to each group regardless of how many processes are in the groups.
75. Define swap device
The memory management system monitors the amount of available primary
memory and may periodically write processes to a secondary memory device called
the swap device to provide more space in primary memory.
76. Define demand paging policy
The demand paging policy transferring memory pages instead of processes to
and from a secondary device. The entire process does not have to reside in main
memory to execute and the kernel loads pages for a process on demand when a
process references the pages.
77. What do you mean by map?
The kernel maintains the free space for the swap device in an incore table
called a map. Maps used for other resources besides the swap device allows a first fit
allocation of contiguous blocks of a resource.
78. What do you mean by protection fault?
The process accessed a valid page but the permission bits associated with the
page did not permit access. A process also incurs a protection fault when it attempts
to write a page whose copy on write bit was set during the fork system call.
79. What are the different stage are specified ad device configuration?
Administrators can hard_code configuration data into files that are compiled
and linked when building the kernel code
Administrator can supply configuration information after the system is already
running; the kernel updates internal configuration tables dynamically.
Self identifying devices permit the kernel to recognize which devices are
installed. The configuration procedure generates or fills in tables.
80. What are the different switch tables available in UNIX?
Block device switch table and character device switch table.
81. What is the purpose of icotl function?
It catch all entry point for device specific commands, allowing a process to set
hardware options associated with a device and software options associated with the
driver.
82. What are the functions of line discipline?
To parse input strings into lines
To process erase characters
To process a kill character
To echo received character to a sequence of blank spaces.
To generate signals to processes for terminal hang-ups, line breaks.
To allow a raw mode that does not interpret special characters.
83. What do you mean by stream?
A stream is a full duplex connection between a process and a device driver. It
consists of a set of linearly linked queue pairs, one member of each pair for input and
other for output.
84. What do you mean by pseudo terminal or pty?
A pty is a software device that operates in pairs: output directed to one
member of the pair is sent to the input of the other member; input is sent to the
upstream module.
85. What are the input needed for loading the region?
Pointer to per process region table entry
Virtual address to load region
Inode pointer of file for loading region
Byte offset in file for loading region
Byte count for amount of data to load
86. What are the different methods available to identify the address?
The driver gets the address in two ways
i. Either the strategy procedure uses a buffer from the buffer pool and the buffer
header contains the device and block number or the read and write procedures
are passed the minor number as a parameter.
ii. They convert the byte offset saved in the u area to the appropriate blok address.
87. What do you mean by shared memory?
Processes can communicate directly with each other by sharing parts of their
virtual address space and then reading and writing the data stored in the shared
memory.
88. What are the elements of system V semaphore?
A value of a semaphore
The process ID of the last process to manipulate the semaphore
The number of processes waiting for the semaphore value to increase
The number of processes waiting for the semaphore value equal to 0
89. What is the format of each element of oplist?
o The semaphore number identifying the semaphore array entry being operated on
o The operation and flags
90. What are the different types of page fault?
Validity faults and protection faults
91. When the validity fault occurs?
If a process attempts to access a page whose valid bit is not set it incurs a
validity fault and the kernel invokes the validity fault handler.
92. What are the inputs needed for attaching a region?
Pointer to region being attached
Process to which region is being attached
Virtual address in process where region will be attached
Region type.
93. What is the purpose of dup and mount system call?
The dup system call copies a file descriptor into the first free slot of the user
file descriptor table, returning new file descriptor to the user.
The mount system call connects the file system in a specified section of a
disk to the existing file system hierarchy.
94. Write down the algorithm for process scheduling.
Algorithm for process scheduling
Input and output are none
{
while(no process picked to execute)
{
for(every process on run queue)
pick highest priority process that is loaded in memory;
if (no process eligible to execute)
idle the machine;
}
remove chosen process from run queue;
switch context to that of chosen process, resume its execution.
}
95. Define page.
The memory management hardware divides physical memory into a set of
equal sized blocks called pages.
96. What are the information available in page table entry?
The page table entries contain machine dependent information such as
permission bits to allow reading or writing of the page.
97. What are the different types of pipes?
Unnamed pipe, and named pipe(FIFO)
98. How will you open and close the devices?
The devices are opened or closed by using the ordinary file functions open
and close, because the devices are also treated as a file.
99. What is the difference between close and shutdown?
In socket communication the close function closes both the connections. The
shutdown function closes only the required connection.
100.Write down the system calls used for TCP communication.
socket, bind, listen, accept, connect,send, recv, close.
Descriptive questions and key
1. Explain in detail about the high level features of UNIX system
a. List down the file system characteristics
b. Explain in detail about the file system
c. Explain about process control
d. Explain about building block primitives.
2. Explain the architecture of UNIX operating system.
Draw the block diagram of system kernel
o Explain about process control subsystem
o Explain about file subsystem, buffer cache.
o Explain about IPC, scheduler, memory management
o Explain about drivers and interfaces.
3. Explain in detail about the processes
Explain about process, process creation, process
termination
Explain basic process states
Explain process state transition diagram
Explain about context switch
4. Explain the scenarios for retrieval of a buffer.
List down the different scenarios for retrieval a buffer
Explain each scenario with diagram.
Explain the algorithms getblk, brelse, bread, bwrite, breada
Advantages and disadvantages of the buffer cache
5. Explain the manipulation of the process address space
Explain the following
Locking and unlocking a region
Allocating a region with algorithm
Attaching a region to a process with algorithm
Changing the size of region with algorithm
Loading a region freeing a region
Freeing a region
Detaching a region from process
Duplicating a region
6. Explain in detail about process creation
Explain process creation and list of operations during fork
Algorithm for fork and explanation
Example with explanation
7. Explain in detail about process termination
a. Explain process termination
b. Algorithm for process termination
c. Explanation of awaiting process termination
d. Algorithm for wait
e. Example
8. Explain in detail about process scheduling
Explain the following
System configuration
System calls and driver interface
Open and closing device files
Read and write operations
Strategy interface
ioctl function
Interrupt handlers
9. Explain in detail about process states and transitions.
Explain the following
List down the states
Draw the state transition diagram
Explain the diagram
Explain the data structures related to process
10. Explain in detail about the manipulation of process address space
Explain the following operations with necessary algorithms
Locking and unlocking a region
Allocating a region
Changing the size of region
Loading a region
Freeing a region
Detaching a region
11. Explain in detail about saving the context of a process.
Explain the following in detail
Interrupts and exceptions
System call interface
Context switch
Copying data between system and user address space
12. Explain in detail about the context of a process
Explain in detail about the following components with necessary data structures
User level context
Register level context
System level context
13. Explain the system calls that return file descriptors as output
Explain the following system calls with the necessary algorithms and example
Open
Creat
Dup
Pipe
Close
14. Explain the functions related to file I/O
Explain the following functions in detail with algorithm
Read
Write
Lseek
15. Explain in detail about the functions which are used to manipulate the files tree
structure
Explain the functions chdir and chown with necessay algorithms and example.
16. Explain in detail about pipes
Explain about pipe system call
Explain about opening a named pipe
Explain about reading and writing pipes
Explain about closing pipes with example
17. Explain in detail about mounting and un mounting a file system
Explain about the system calls mount and unmount
Explain the entries of mount table
Explain in detail about algorithm for mounting
Explain in detail about algorithm for unmounting
18. Explain in detail about swapping
Explain about allocation of swap space
Explain in detail about swapping processes out
o Explain fork swap and expansion swap
Explain swapping processes in with algorithm
19. Explain in detail about demand paging
Explain in detail about data structures for demand paging
Explain fork and exec in a paging system
Explain page stealer process
20. Explain in detail about page fault and fault handlers
Define page fault
o Explain validity fault handler with algorithm
o Explain protection fault handler with algorithm
21. Explain in detail about the driver interfaces
Explain about
System configuration


System calls and driver interface
o Explain about open and close a device
o Explain about read and write a device
o Explain about ioctl function
22. Explain in detail about terminal drivers
Define terminal drivers
List down the functions of line discipline
Explain about clists
Explain the terminal driver in canonical mode
Explain the terminal driver in raw mode
Explain in detail about terminal polling and logging in
23. Explain in detail about process tracing
Explain the structure of debugging process
Explain the ptrace system call with example
Explain the advantages and disadvantages about ptrace function
24. Explain in detail about system V IPC mechanisms
Write down the purpose of system V IPC mechanisms
List down different IPC mechanisms
Explain in detail about the above mechanisms with necessary
algorithms
25. Explain in detail about network communication
Explain in detail about the socket communications
Explain the system calls related to UDP and TCP communications
Explain the steps for communication between devices using the above sockets

Das könnte Ihnen auch gefallen