Friday, 21 September 2012

OS Interview Questions-4


1.What are the disadvantages of context switching?
Ans: Time taken for switching from one process to other is pure over head. Because the system does no useful work while switching. So one of the solutions is to go for threading when ever possible.

2.What are co-operating processes?
Ans: The processes which share system resources as data among each other. Also the processes can communicate with each other via interprocess communication facility generally used in distributed systems. The best example is chat program used on the www.

3.What is a thread?
Ans: A thread is a program line under execution. Thread sometimes called a light-weight process, is a basic unit of CPU utilization; it comprises a thread id, a program counter, a register set, and a stack.

4.What are the benefits of multithreaded programming?
Ans:
1. Responsiveness (needn’t to wait for a lengthy process)
2. Resources sharing
3. Economy (Context switching between threads is easy)
4. Utilization of multiprocessor architectures (perfect utilization of the multiple processors).

5.What are types of threads?
Ans:
1. User thread
2. Kernel thread
User threads are easy to create and use but the disadvantage is that if they perform a blocking system calls the kernel is engaged completely to the single user thread blocking other processes. They are created in user space.
Kernel threads are supported directly by the operating system. They are slower to create and manage. Most of the OS like Windows NT, Windows 2000, Solaris2, BeOS, and Tru64 Unix support kernel threading.

6.Which category the java thread do fall in?
Ans: Java threads are created and managed by the java virtual machine, they do not easily fall under the category of either user or kernel thread……

7.What are multithreading models?
Ans: Many OS provide both kernel threading and user threading. They are called multithreading models. They are of three types:
1. Many-to-one model (many user level thread and one kernel thread).
2. One-to-one model
3. Many-to –many
In the first model only one user can access the kernel thread by not allowing multi-processing. 
Example: Green threads of Solaris.
The second model allows multiple threads to run on parallel processing systems. Creating user thread needs to create corresponding kernel thread (disadvantage).
Example: Windows NT, Windows 2000, OS/2.
The third model allows the user to create as many threads as necessary and the corresponding kernel threads can run in parallel on a multiprocessor.
Example: Solaris2, IRIX, HP-UX, and Tru64 Unix.

8.What is a P-thread?
Ans: P-thread refers to the POSIX standard (IEEE 1003.1c) defining an API for thread creation and synchronization. This is a specification for thread behavior, not an implementation. The windows OS have generally not supported the P-threads.

9.What are java threads?
Ans: Java is one of the small number of languages that support at the language level for the creation and management of threads. However, because threads are managed by the java virtual machine (JVM), not by a user-level library or kernel, it is difficult to classify Java threads as either user- or kernel-level.

10.What is process synchronization?
Ans: A situation, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called race condition. To guard against the race condition we need to ensure that only one process at a time can be manipulating the same data. The technique we use for this is called process synchronization.

No comments:

Post a Comment