This site is 100% ad supported. Please add an exception to adblock for this site.

UNIX

Terms

undefined, object
copy deck
How are devices represented in UNIX?
All devices are represented by files called special files that are located in the /dev directory. Thus, device 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
What is 'inode'?
All UNIX files have its description stored in a structure called 'inode.' the inode contains info about the file - size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have
Brief about directory representation in UNIX
A UNIX directory is a file containing 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 the list o
What are the Unix system calls for I/O?
open(pathname,flag,mode) - open file creat(pathname,mode) - create file close(filedes) - close an open file read(filedes,buffer,bytes) - read data from an open file write(filedes,buffer,bytes) - write data to an open file lseek(filedes,offset,from) -
How do you change File Access Permissions?
Every file has the 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 ac
What are links and symbolic links in UNIX file system?
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 contai
What is a FIFO?
FIFO is 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 a named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in int
How do you create special files like named pipes and device files?
The system call mknod creates special files in the following sequence. 1. kernel assigns new inode, 2. sets the file type to indicate the file is a pipe,directory or special file, 3. If it is a device file, it makes the other entries like major, minor
Discuss the mount and unmount system calls
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 tr
How does the inode map to a data block of a file?
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 addre
What is a shell?
A shell is an interactive user interface to operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute th
Brief about the initial process sequence while the system boots up.
While booting, special process called the 'swapper' or 'scheduler' is created by the Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper in turn creates 3 children: the process dispatcher, vhand,
What are various IDs associated with a process?
Unix identifies each process with a unique integer called ProcessID. The process that executes the request for the creation of the process is called the 'parent process' whose PID is 'Parent Process ID'. Every process is associated with a particular use
Explain the fork() system call.
The 'fork()' call is used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. We can tell which is which by checking the return value from 'fork()'. The parent ge
Predict the output of the following program code: main() { fork(); printf("Hello World!"); }
Hello World!Hello World! 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
Predict the output of the following program code. main() { fork();fork();fork(); printf("Hello World!"); }
"Hello World!" will be printed 8 times. 2^n times where n is the number of calls to fork();
List the system calls used for process management.
fork() - to create a new process exec() - to execute a new program in a process wait() - to wait until a created process completes its execution exit() - to exit from a process execution getpid() - to get a process identifier of the current process g
How can you get/set an environment variable from a program?
Getting the value of an environment variable is done by using 'getenv()'. Setting the value of an environment variable is done by using 'putenv()'.
How can a parent and child process communicate?
A parent and child can communicate through any of the normal inter-process communication schemes (pipes,sockets,message queues,shared memory), but also have some special ways to communicate that take advantage of their relationship as a parent and child.
What is a zombie?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this inf
What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix processes have the following states: Running: The process is either running or it is ready to run Waiting: The process is waiting for an event or for a resource. Stopped: The
What happens when you execute a program?
When you execute a program on your UNIX system, the system creates a special environment for the program. This environment contains everything needed for the system to run the program as if no other program were running on the system. Each process has p
What happens when you execute a command?
When you enter 'ls' command to look at the contents of your current working directory, UNIX does a series of things to create an environment for ls and run it: The shell has UNIX perform a fork. This creates a new process that the shell will use to run
What is a Daemon?
A daemon is a process that detaches itself from the terminal and runs, disconnected in the background, waiting for requests and responding to them. It can also be defined as the background process that does not belong to a terminal sessions. Many system
What is the 'ps' command for?
The ps command prints the process status for some or all of the running processes. The information given are the process identification number (PID), the amount of time the process has taken to execute so far, etc.
How would you kill a process?
The kill command takes the PID as one argument; this identifies the process to terminate. The PID of the process can be got using 'ps' command.
What is the advantage of executing a process in the background?
The most common reason to put a process in the background is to allow you to do something else interactively without waiting for the process to complete. At the end of the command, you add the special background symbol, &. This symbol tells your shell to
How do you execute one program from within another?
The system calls for low-level process creation are execlp() and execvp(). The execlp call overlays the existing program with the new one, runs that and exists. The original program gets back control only when an error occurs. execlp(path,file_name,arg
What is IPC? What are the various schemes available?
The term IPC(Inter-Process Communication) describes the various ways by which different processes running on some operating system communicate with each other. Various schemes available are as follows: Pipes - One-way communication scheme through which
What is the difference between Swapping and Paging?
Swapping: Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implement and overhead to the system. Swapping systems does not handle memory
What is the major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management?
Historic Unix uses Swapping, entire process is transferred to the main memory from the swap device, whereas the Unix System V uses Demand Paging, only part of the process is moved to main memory. Historic Unix uses one Swap Device and Unix System V allow
What is the main goal of Memory Management?
It decides which process should reside in main memory, Manages the pats of the virtual address space of a process which is non-core resident, Monitors the available main memory and periodically writes the processes into the swap device to provide more pro
What is a Map?
A Map is an array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of resource units available there. This allows First-Fit allocation of contiguous blocks of a resource. Initially, the Ma
What scheme does the Kernel in Unix Systme V follow while choosing a swap device among the multiple swap devices?
Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V.
What is a Region?
A Region is a continuous area of a process's address space (such as text, data, and stack). The kernel in a Region Table that is local to the process maintains region. Regions are sharable among the process.
What are the events done by the Kernel after a process is being swapped out from the main memory?
When the Kernel swaps the process out of a primary memory, it performs the following: Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory. Kernel allocates th
Is the Process before and after the swap the same? Give reason.
Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while the swapping Kernel do not bother ab
What do you mean by u-area(user area) or u-block?
This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area.
What are the entities that are swapped out of the main memory while swapping the process out of main memory?
All memory space occupied by the process, process's u-area, and Kernel stack are swapped out, theoretically. Practically, if the process's u-area contains the Address Translation Tables for the process then Kernel implementations to not swap the u-area.
What is Fork swap?
fork() is a system call to create a child process. When the parent process calls fork() system call, the child process is created and if there is a shortage of memory, the child process is sent to the ready-to-run state in the swap device, and return to
What is Expansion swap?
At the time when any process requires more memory than is currently allocated, the Kernel performs Expansion swap. To do this, Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address
How does the Swapper work?
The swapper is the only process that swaps processes. The swapper operates only in Kernel mode and it does not use system calls. Instead, it uses internal Kernel functions for swapping. It is the archetype of all kernel processes.
What are the processes that are not bothered by the swapper? Give Reason.
Zombie processes: They do not take up any physical memory. Processes locked in memories that are updating the region of the process. Kernel swaps only the sleeping processes rather than the ready-to-run processes, as they have a higher probability of b
What are the requirements for a swapper to work?
The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if not found then it will look for ready-to-run processes for swapping. But the major requirement for the swapper to work is the ready-to-run process mus
What are the criteria for choosing a process for swapping into memory from the swap device?
The resident time of the processes in the swap device, the priority of the processes and the amount of time the processes had been swapped out.
What are the criteria for choosing a process for swapping out of the memory to the swap device?
The process's memory resident time Priority of the process The nice value
What do you mean by nice value?
The Nice value is the value that controls (increments or decrements) the priority of the process. This value that is returned by the nice() system call. The equation for using nice value is : Priority = (recent CPU usage / constant) + (base - priority)
What are conditions on which deadlock can occur while swapping the processes?
All processes in the main memory are asleep. All ready-to-run processes are swapped out. There is no space in the swap device for the new incoming process that are swapped out of the main memory. There is no space in main memory for the new incoming pr
What are conditions for a machine to support Demand Paging?
The memory architecture must be based on Pages. The machine must support restartable instructions.
What is the principal of locality?
It's the nature of processes that they refer only to the small subset of the total data space of the process. i.e. the process frequently calls the same subroutines or executes the loop instructions.
What is the working set of a process?
The set of pages are referred by the process in the last n, references, where n is called the working set of the process.
What is the window of the working set of a process?
The window of the working set of a process is the total number in which the process had referred the set of pages in the working set of the process.
What is called a page fault?
A page fault is referring to the situation when the process addresses a page in th working set of the process but the process fails to locate the page in the working set. And on a page fault, the kernel updates the working set by reading the page from th
What are the data structures that are used for Demand Paging?
The Kernel contains 4 data structures for Demand paging. They are: Page table entries Disk block descriptors Page frame data table (pfdata) Swap-use table
What are the bits that support the demand paging?
Valid, Reference, Modify, Copy on write, Age. These bits are part of the page table entry, which includes the physical address of the page and the protection bits. Page address Age Copy on write Modify Reference Valid Protection
How does the Kernel handle the fork() system call in traditional Unix and in System V Unix, while swapping?
Kernel in traditional Unix, makes the duplicate copy of the parent's address space and attaches it to the child's process, while swapping. Kernel in System V Unix, manipulates the region tables, page table and pfdata table entries, by incrementing the re
Difference between the fork() and vfork() system call?
During the fork() system call, the Kernel makes a copy of the parent process's address space and attaches it to the child process. But the vfork() system call does not make a copy of the parent's address space, so it is faster than the fork() system call
What is the BSS (Bock Started by Symbol)?
A data representation at the machine level that has initial values when a program starts and tells how much space the kernel allocates for the un-initialized data. Kernel initializes it to zero at run-time.
What is a Page-Stealer process?
This is the Kernel process that makes room for the incoming pages, by swapping the memory pages that are not part of the working set of a process. Page-Stealer is created by the Kernel at the system initialization and invokes it throughout the lifetime o
Name two paging states for a page in memory?
The 2 paging states are: The page is aging and not yet eligible for swapping. The page is eligible for swapping but not yet eligible for reassignment to other virtual address space.
What are the phases of swapping a page from memory?
Page stealer finds the page eligible for swapping and places the page number in the list of pages to be swapped. Kernel copies the page to a swap device when necessary and clears the valid bit in the page table entry, decrements the pfdata reference count
What is a page fault? Its types?
Page fault refers to the situation of not having a page in main memory when any process references it. There are two types of page faults: Validity fault Protection fault
In what way are the Fault Handlers and the Interrupt Handlers different?
Fault handlers are also an interrupt handler with an exception that the interrupt handlers cannot sleep. Fault handlers sleep in the context of the process that caused the memory fault. The fault refers to the running process and no arbitrary processes
What is a validity fault?
If a process referring to a page in main memory whose valid bit is not set, it results in a validity fault. The valid bit is not set for those pages: that are outside the virtual address space of a process, that are part of the virtual address space o
What does the swapping system do if it identifies the illegal page for swapping?
If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a Segmentation Violation signal to the offending process. This happens when the swapping system
What are the states that the page can be in, after causing a page fault?
On a swap device and not in memory, On the free page list in the main memory, In an executable file, Marked 'demand zero', Marked 'demaind fill'
In what way does the validity fault handler conclude?
It sets the valid bit of the page by clearing the modify bit It recalculates the process priority.
At what mode does the fault handler execute?
At Kernel mode
What does a protection fault mean?
A protection fault refers to the process accessing the pages, which do not have access permission. A process also incur th protection fault when it attempts to write a page whose copy on write bit is set during fork.
Explain different types of Unix Systems.
The most widely used are: 1. System V (AT&T) 2. AIX (IBM) 3. BSD (Berkeley) 4. Solaris (SUN) 5. Xenix (A PC version of Unix)
What are typical system directories below the root directory?
1. /bin - contains many programs executed by users 2. /etc - files used by the administrator 3. /dev - hardware devices 4. /lib - system libraries 5. /usr - application software 6. /home - home directories for different users
What is the significance of the 'tee' command?
It reads the standard input and sends it to the standards output while redirecting a copy of what is read to the file specified by the user.
What is the difference between cmp and diff commands?
cmp - compares two files byte by byte and displays the first mismatch diff - tells the changes to be made to make the files identical
Write a command to kill the last background job?
kill $!
What is the command to create a new file system in UNIX?
mkfs
Major differences between Solaris and Linux?
1. Solaris is a consistent operating system with a fairly established release schedule; Linux is a distributed development project within many strains and limited oversight 2. Solaris 10 adds zfs and DTrace 3. Solaris 10 adds process rights management
Write a command to find all files which have been accessed within the last 30 days.
find / -type f -atime -30
What are the file differences between Solaris and Linux?
NFS Server: /etc/dfs/dfstab - Solaris /etc/exports - Linux Automounter: /etc/auto_master,/etc/auto_home - S /etc/auto.master,/etc/auto.home - L File System Table: /etc/vfstab - S, /etc/fstab - L Kernel list of mounted file systems: /etc/mnttab
What are the UNIX Run levels?
Shutdown - 0 Single user / Maintenance - S/1 Multi-user, no NFS - 2 Multi-user mode - 3 Multi-use with GUI - 3(S), 5(L) Shutdown with power off - 5(S), 0(L) Reboot - 6
What are the different levels of raid?
Raid 0 - Striped set (no redundancy; increased performance) Raid 1 - Mirrored set (redundancy; faster reads; slower writes) Raid 0+1: striped set + mirrored set (4 disk minimum); mirror of stripes Raid 1+0: stripe of mirrors Raid 3/4: striped with d

Deck Info

80

blynch

permalink