InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
List The System Calls Used For Process Management? |
|
Answer» SYSTEM calls Description:
System calls Description: |
|
| 2. |
Predict The Output Of The Following Program Code Main() { Fork(); Fork(); Fork(); Printf("hello World!"); } |
|
Answer» "HELLO World" will be printed 8 times. 2^N times where n is the number of CALLS to fork() "Hello World" will be printed 8 times. Explanation: 2^n times where n is the number of calls to fork() |
|
| 3. |
Predict The Output Of The Following Program Code Main(), { Fork(); Printf("hello World!"); } |
|
Answer» Hello World!Hello World! Explanation: The FORK creates a child that is a duplicate of the parent PROCESS. The child begins from the fork().All the STATEMENTS after the call to fork() will be executed twice.(once by the parent process and other by child). The STATEMENT before fork() is executed only by the parent process. Hello World!Hello World! Explanation: The fork creates a child that is a duplicate of the parent process. The child begins from the fork().All the statements after the call to fork() will be executed twice.(once by the parent process and other by child). The statement before fork() is executed only by the parent process. |
|
| 4. |
Brief About The Initial Process Sequence While The System Boots Up? |
|
Answer» While booting, special process CALLED the 'swapper' or 'scheduler' is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 CHILDREN:
with IDs 1,2 and 3 respectively. This is done by executing the file /etc/init. Process dispatcher gives birth to the SHELL. Unix keeps track of all the processes in an INTERNAL data structure called the Process Table (listing command is ps -EL). While booting, special process called the 'swapper' or 'scheduler' is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children: with IDs 1,2 and 3 respectively. This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. Unix keeps track of all the processes in an internal data structure called the Process Table (listing command is ps -el). |
|
| 5. |
How Does The Inode Map To Data Block Of A File? |
|
Answer» Inode has 13 block addresses. The FIRST 10 are direct block addresses of the first 10 data blocks in the file. The 11th address points to a ONE-level index block. The 12th address points to a two-level (double in-direction) index block. The 13TH address points to a three-level(triple in-direction)index block. This provides a very large maximum file size with efficient access to large files, but also SMALL files are accessed directly in one disk read. Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks in the file. The 11th address points to a one-level index block. The 12th address points to a two-level (double in-direction) index block. The 13th address points to a three-level(triple in-direction)index block. This provides a very large maximum file size with efficient access to large files, but also small files are accessed directly in one disk read. |
|
| 6. |
Discuss The Mount And Unmount System Calls? |
|
Answer» The privileged MOUNT system call is USED to attach a file system to a directory of another file system; the unmount system call detaches a file system. When you mount another file system on to your directory, you are essentially SPLICING one directory tree onto a branch in another directory tree. The first argument to mount call is the mount point, that is , a directory in the current file naming system. The second argument is the file system to mount to that point. When you insert a CDROM to your unix system's drive, the file system in the cdrom AUTOMATICALLY mounts to /dev/cdrom in your system. The privileged mount system call is used to attach a file system to a directory of another file system; the unmount system call detaches a file system. When you mount another file system on to your directory, you are essentially splicing one directory tree onto a branch in another directory tree. The first argument to mount call is the mount point, that is , a directory in the current file naming system. The second argument is the file system to mount to that point. When you insert a cdrom to your unix system's drive, the file system in the cdrom automatically mounts to /dev/cdrom in your system. |
|
| 7. |
How Do You Create Special Files Like Named Pipes And Device Files? |
|
Answer» The system call mknod creates special FILES in the following sequence:
For example: If the device is a disk, major device number refers to the disk controller and minor device number is the disk. The system call mknod creates special files in the following sequence: For example: If the device is a disk, major device number refers to the disk controller and minor device number is the disk. |
|
| 8. |
What Is A Fifo? |
|
Answer» FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the ORDER written. It is USED in interprocess communication where a PROCESS writes to one END of the pipe (producer) and the other reads from the other end (consumer). FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in interprocess communication where a process writes to one end of the pipe (producer) and the other reads from the other end (consumer). |
|
| 9. |
What Are Links And Symbolic Links In Unix File System? |
|
Answer» A LINK is a second name (not a file) for a file. LINKS can be used to assign more than ONE name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers. Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are ELIMINATED in symbolic links. Commands for linking files are:
A link is a second name (not a file) for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers. Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links. Commands for linking files are: |
|
| 10. |
How Do You Change File Access Permissions? |
|
Answer» Every file has following attributes: owner's USER ID ( 16 bit integer ) owner's group ID ( 16 bit integer ) File access mode word 'r w x -r w x- r w x' (user permission-group permission-others permission) r-READ, w-write, x-execute To change the access mode, we use chmod(filename,mode). Example 1: To change mode of myfile to 'rw-rw-r–' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as: chmod(myfile,0664) . Each operation is REPRESENTED by DISCRETE values 'r' is 4 'w' is 2 'x' is 1 Therefore, for 'rw' the value is 6(4+2). Example 2: To change mode of myfile to 'rwxr–r–' we give the args as: chmod(myfile,0744). Every file has following attributes: owner's user ID ( 16 bit integer ) owner's group ID ( 16 bit integer ) File access mode word 'r w x -r w x- r w x' (user permission-group permission-others permission) r-read, w-write, x-execute To change the access mode, we use chmod(filename,mode). Example 1: To change mode of myfile to 'rw-rw-r–' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as: chmod(myfile,0664) . Each operation is represented by discrete values 'r' is 4 'w' is 2 'x' is 1 Therefore, for 'rw' the value is 6(4+2). Example 2: To change mode of myfile to 'rwxr–r–' we give the args as: chmod(myfile,0744). |
|
| 11. |
What Are The Unix System Calls For I/o? |
Answer»
The difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations. The difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations. |
|
| 12. |
Brief About The Directory Representation In Unix? |
|
Answer» A UNIX directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are CREATED, kernel makes two ENTRIES named '.' (refers to the directory itself) and '..' (refers to PARENT directory). SYSTEM call for creating directory is mkdir (pathname, mode). A Unix directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are created, kernel makes two entries named '.' (refers to the directory itself) and '..' (refers to parent directory). System call for creating directory is mkdir (pathname, mode). |
|
| 13. |
How Are Devices Represented In Unix? |
|
Answer» All devices are represented by files called special files that are located in/dev DIRECTORY. Thus, device files and other files are NAMED and accessed in the same way. A 'regular FILE' is just an ordinary data file in the disk. A 'block special file' represents a device with CHARACTERISTICS SIMILAR to a disk (data transfer in terms of blocks). A 'character special file' represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order). All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way. A 'regular file' is just an ordinary data file in the disk. A 'block special file' represents a device with characteristics similar to a disk (data transfer in terms of blocks). A 'character special file' represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order). |
|