IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

UNIX Process Management - Interview Questions and Answers

@ : Home > Technical Interview > UNIX Process Management > Interview Questions

1. Brief about the initial process sequence while the system boots up.

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:

  1. the process dispatcher,
  2. vhand and
  3. dbflush
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).

2. 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 creation of a process is called the 'parent process' whose PID is 'Parent Process ID'. Every process is associated with a particular user called the 'owner' who has privileges over the process. The identification for the user is 'UserID'. Owner is the user who executes the process. Process also has 'Effective User ID' which determines the access privileges for accessing resources like files.

  • getpid() -process id
  • getppid() -parent process id
  • getuid() -user id
  • geteuid() -effective user id

3. Explain fork() system call.

The 'fork()' 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 gets the child's pid returned to him, but the child gets 0 returned to him.

4. 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.

5. Predict the output of the following program code
main()
{
   fork(); fork(); fork();
   printf("Hello World!");
}

Answer: "Hello World" will be printed 8 times.
Explanation: 2^n times where n is the number of calls to fork();

6. List the system calls used for process management:

System calls - Description
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
getppid() - To get parent process identifier
nice()   - To bias the existing priority of a process
brk()   - To increase/decrease the data segment size of a process


© 2008-2013 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!