0% found this document useful (0 votes)
72 views3 pages

IPC Multiple Choice Questions for OS

This document contains 16 multiple choice questions about interprocess communication mechanisms: 1) IPC involves system calls to allow communication between processes. 2) The OS uses a data structure in kernel space to facilitate IPC. 3) When a process is forked, properties like process ID and stack are inherited by the child process.

Uploaded by

vipuljain1989
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views3 pages

IPC Multiple Choice Questions for OS

This document contains 16 multiple choice questions about interprocess communication mechanisms: 1) IPC involves system calls to allow communication between processes. 2) The OS uses a data structure in kernel space to facilitate IPC. 3) When a process is forked, properties like process ID and stack are inherited by the child process.

Uploaded by

vipuljain1989
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Operating Systems/Interprocess Communication Multiple Choice Questions

Multiple Choice Questions


1. Which of the following is true in the context of Inter-process communication:
a. It is like a user defined procedure call.
b. It is like user defined a function call.
c. It is a system call.
2. For IPC communication the OS employs an internally defined data-structure which is
defined:
a. In user space
b. As a separate area which is neither in user space nor in kernel space
c. In kernel space
3. When a process is forked the child process inherits some properties. Which of the
following properties are inherited?
a. The process id.
b. The process code
c. All the defined program variables
d. The priority of the process.
e. The stack
4. As a function fork evaluates to true in parent
a. True
b. False
5. Which of the following belong to valid commands in the exec family?
a. execl( )
b. exect( )
c. execlp( )
d. exelp( )
e. execp( )
6. On populating code in a child process which of the following conditions hold:
a. The process becomes independent of the parent – its PPID is destroyed.
b. A new subdirectory is created to locate the new process.
c. The environmental variables remain unchanged.
d. A new stack is defined for the new process.

[Link]/IISc Bangalore M7/V1/June 04/1


Operating Systems/Interprocess Communication Multiple Choice Questions

7. When a pipe is defined – its either end can be utilized for reading / writing
a. True
b. False
8. Which of the following are true in the case of a pipe as a mechanism of IPC?
a. A pipe is for uni-directional communication.
b. A pipe uses a buffer and the size of the buffer can be specified by the user.
c. Pipes can be extended to establish communication between processes resident
on different machines provided we use the process id together with IP address
of the machines.
d. Pipes can not support broadcast.
9. Which of the following statements are true for shared files as a mechanism for IPC.
a. Define a file_name in the sender and give access permission for the world.
b. Define shared file directory as a shared object.
c. Define a file pointer as a shared object and use a semaphore in mutually
exclusive manner.
d. Files can be shared any way if the processes belong to the users in the same
group.
10. Suppose we use a shared file pointer mechanism for IPC. Also, suppose there are
several processes that read this file but there is one and only one clearly identified
process that writes into it Reflect on the following:
a. We do not need semaphore protection as only one process is writing.
b. We need one semaphore to ensure exclusive write operation.
c. We need as many semaphores as the processes using the shared file
pointer.
11. Which of the following statements are true for shared memory as a IPC mechanism.
a. The shared memory is defined as a “safe area” and gets attached to the the
processes that share this area.
b. The shared memory model uses an array which is defined in all the processes
that share the area.
c. The shared memory is a specific chunk of main memory which is in the temp
directory and is accessible during the life time of the processes sharing it.

[Link]/IISc Bangalore M7/V1/June 04/2


Operating Systems/Interprocess Communication Multiple Choice Questions

d. It is desirable that the shared memory area is de-allocated for garbage


collection after use.
e. Processes must belong to the same host for shared memory area as a
mechanism for IPC.
12. Which of the following are required when a shared memory area is used for IPC:
a. Data size in bytes
b. Pointer to the data area
c. First attach time
d. Last attach time
e. First detach time
f. Last detach time
g. Last change time
13. Which of these mechanism is supported in the Hyper-cube:
a. Shared file pointer
b. Shared memory area
c. Message based communication
d. None of the above – it has its own IPC
14. A msgsnd() or msgrcv() returns an integer. Which of the following are true
statements:
a. Return value > 1 indicates a correct send or receive
b. Return value = 0 indicates a correct send or receive
c. Return value = -1 indicates an error has occurred
15. Which of the following are possibly acceptable responses to a signal:
a. Receive but never respond
b. Receive and always respond
c. Receive and respond selectively
16. A mail box is an indirect mode of communication
a. True
b. False

[Link]/IISc Bangalore M7/V1/June 04/3

Common questions

Powered by AI

Shared memory allows multiple processes to access a common memory region, facilitating fast data exchange without the overhead of system calls for each access, making it efficient for large data volumes . In contrast, pipes provide a unidirectional communication channel through which data is passed between processes, necessitating buffer management and potentially involving overhead due to system call dependencies . Shared memory is generally faster but requires synchronization mechanisms like semaphores to prevent race conditions, which can be complex to manage .

Semaphores in conjunction with shared memory areas provide synchronization and mutual exclusion to prevent concurrent access issues such as race conditions. By controlling access, semaphores ensure that only one process can write or modify memory at a time, facilitating orderly and predictable interprocess communication . This is particularly important in maintaining data integrity and preventing processes from potentially corrupting shared data via overlapping useful operations .

To use a shared memory area for interprocess communication, the shared memory must be defined as a 'safe area' and attached to the processes sharing it . It is also necessary to manage the shared memory's lifecycle, including de-allocating it for garbage collection after use . Processes must belong to the same host as shared memory IPC does not support remote connections . Additionally, the data size, pointers, and timestamps for attachment and detachment should be managed effectively .

The exec() function family in operating systems allows a process to replace its current execution context, including its code, data, and stack, with a new program. This is achieved without changing the process ID, which allows smooth transitions within multi-layered process operations . The exec() functions (like execl(), execlp(), etc.) provide various means to load and execute different programs using arguments and paths, enhancing flexibility and modularity in process management workflows .

Mailboxes, as an indirect mode of communication, enable message passing between processes that do not share a direct communication link. This abstraction facilitates decoupled communication, allowing processes to send and receive messages asynchronously . While this offers flexibility and scalability in designing distributed applications, it may introduce complexities in managing message queues and ensuring message delivery order . Additionally, it can result in increased latency compared to directly connected IPC mechanisms.

In a forked process, the child process does not inherit the process ID of the parent . Additionally, while the code and stack are duplicated, the child does not inherit certain runtime specifics such as open file descriptors (existing ones are shared but positioned separately), pending signals, and certain memory mappings . This delineation ensures that child processes start with a consistent state while not interfering with the parent’s execution environment.

Pipes inherently support uni-directional communication between processes on the same machine and cannot directly communicate across different machines due to their local nature and reliance on internal data structures managed by the operating system's kernel space . To achieve inter-machine communication, alternative methods such as network-based IPC like sockets or shared networked file systems would be necessary, and pipes alone are insufficient .

The return values of msgsnd() or msgrcv() functions provide crucial information regarding the state of message operations. A return value greater than 1 indicates successful message sending or receiving . A return value of 0 also generally signifies successful operation, though common practices might dictate considerations depending on context . Conversely, a return value of -1 indicates that a failure occurred, necessitating error handling to address issues like insufficient buffer size or permission errors .

Semaphore protection is necessary in shared file pointer mechanisms for IPC to ensure exclusive access to the shared file, preventing data inconsistencies or race conditions. Specifically, one semaphore is sufficient when there is only one identified process writing to the file, ensuring that no multiple writes occur simultaneously . This prevents concurrent write operations that may lead to data corruption.

Deallocating shared memory areas after their use is critical to freeing up system resources and preventing memory leaks, which can degrade system performance and stability over time . Proper management ensures that the allocation matches the demand, avoiding both excessive consumption of memory and potential security risks associated with lingering data that might be improperly accessed by unauthorized processes . This practice is essential for maintaining an efficient and secure computing environment.

You might also like