📝 Client server communication in the context of processes in operating system (35 MCQs)
Client and Server Processes in Operating System Communication
Client-server communication is an IPC model in which one process requests a service and another process provides it. The client sends a request containing the required operation and data, while the server processes the request and returns a response. This model supports local services and networked applications, allowing programs to cooperate without sharing their complete internal execution state or memory.
Why Service Requests Are Separated Between Processes
Dividing applications into clients and servers improves modularity and allows services to operate independently of requesting programs. A server can manage shared resources, handle multiple clients, and centralise specific operations. However, independent processes require communication channels and suitable request-handling policies. Network-based communication also introduces latency, connection failures, authentication requirements, and the possibility of unavailable servers.
Request Handling Through Sockets and Remote Procedure Calls
A client establishes communication through an appropriate endpoint, commonly using sockets for network communication. It sends a request that the server receives, interprets, and processes. The server returns a response through the established communication mechanism. Remote procedure call (RPC) systems provide higher-level abstractions by presenting remote operations through procedure-like interfaces, while hiding some communication details.
Two Processes Exchanging a Database Query Over TCP
Suppose a client process connects to a database server using TCP and sends a query requesting 25 customer records. The server receives the request, validates it, executes the query, and returns the results through the connection. The client reads the response and processes the returned records. TCP provides an ordered byte stream, not automatic application-level message boundaries.
Concurrent Clients, Response Latency, and Server Reliability
Client-server architecture allows a shared service to support many independent applications and users. Servers may use multiple processes or threads to handle concurrent requests, improving throughput when resources permit. However, excessive client demand can exhaust connections, CPU time, or memory. Network delay, server failure, authentication weaknesses, and poorly managed request queues can also degrade service availability.
Misconceptions About Client-Server Process Communication
'A client and server must execute on separate computers' is incorrect because both can communicate through local IPC. 'TCP preserves application message boundaries' is incorrect because it provides a continuous byte stream. 'A server can process unlimited simultaneous clients' is incorrect because available CPU, memory, connections, and scheduling capacity impose limits.
Exam Focus: Tracing Client Requests and Server Responses
Trace the communication sequence from client connection and request transmission through server processing and response delivery. Distinguish sockets, TCP connections, RPC, and ordinary local procedure calls. Questions may examine concurrent client handling, blocking communication, server process creation, network reliability, and the difference between transport-level byte streams and application-level messages.
Key Terms of Client-Server Communication
- Client - Process requesting a service.
- Server - Process providing a service.
- Socket - Communication endpoint between processes.
- TCP - Reliable ordered byte-stream transport protocol.
- RPC - Remote procedure call mechanism.
- Request - Message asking for a service.
📝 All Client server communication in the context of processes in operating system MCQs
Q1. Which role in the client-server model initiates requests for a service?
📖 Explanation: In the client-server model the client starts communication by sending a request, while the server waits to receive requests and returns results. The clear division of initiating and responding roles is what allows one server to serve many clients over the network or within a single machine.
Q2. Which system call marks a socket as passive so that it can accept incoming connection requests?
📖 Explanation: The listen call turns a bound socket into a passive socket that queues incoming connection requests. The server then calls accept to take a request from that queue. Connect is the client's call to start a connection, so it does not serve the same role.
Q3. What is a remote procedure call?
📖 Explanation: A remote procedure call lets a program call a function that executes on a remote system, while the programmer writes what appears to be an ordinary call. Stubs and the network transport handle the details, so the abstraction hides communication from the calling code while still requiring careful handling of failures.
Q4. Which component converts procedure parameters into a form suitable for transmission across a network in a remote procedure call?
📖 Explanation: Marshalling packs arguments into a message format that can be sent over the network, and unmarshalling reverses the process at the other end. Stubs generated on each side perform this work so that application code can remain unaware of the transmission details.
Q5. Which server design creates a new child process to handle each incoming client request?
📖 Explanation: A concurrent forking server accepts a connection and forks a child that serves the client while the parent returns to accepting new connections. This lets many clients be served at the same time, which an iterative server cannot do since it handles one client at a time.
Q6. A student believes that a client and server must always run on different machines. Which correction is most accurate?
📖 Explanation: The client-server model describes roles and interaction, not physical location. A client and server running on one machine communicate through the same socket interface used across a network. Recognising this helps designers test networked services locally and understand that communication mechanisms, not distances, define the model.
Q7. Why must a server call bind before it calls listen?
📖 Explanation: A socket has no address until it is bound, so clients have nothing to connect to. Listen then prepares the bound socket to accept connections. Reversing the order would leave the socket without a reachable address, which is why the sequence bind, listen, accept is standard.
Q8. Why does an iterative server, which handles one client at a time, suffer when requests take a long time?
📖 Explanation: An iterative server completes each request before accepting the next. A slow request therefore delays every queued client, which raises response times and limits throughput. This weakness motivates concurrent designs in which several requests can progress at once.
Q9. Why does a concurrent server with a pool of worker threads often reduce response time compared with an iterative server?
📖 Explanation: A worker pool allows several requests to proceed concurrently, so a slow request does not block the others. Waiting clients receive service sooner, improving average response time. The reduction is limited by the number of workers and the available resources, so the pool size is a design trade-off.
Q10. Why does a server need a backlog queue for incoming connection requests?
📖 Explanation: Connection requests can arrive faster than the server accepts them. The backlog holds pending requests in the kernel until the server calls accept, so short bursts are absorbed. When the backlog is full, further requests may be refused or delayed, which signals overload.
Q11. Why does TCP connection setup involve a handshake before data is exchanged?
📖 Explanation: The handshake lets client and server confirm they can reach each other and agree on sequence numbers, which underpins reliable and ordered delivery. Without this synchronisation, data could arrive at an endpoint that is not ready or be misordered, so the handshake is a necessary part of establishing a connection.
Q12. Why must a TCP receiver be prepared to handle partial reads, even when the sender sent one message?
📖 Explanation: TCP delivers an ordered stream of bytes, and the boundaries the sender used are not guaranteed to survive. A receiver that assumes one read equals one message will misparse data when a message is split or two combine. Application-level framing is therefore needed to recover message boundaries.
Q13. Why does a stateless server design help a service scale across many replicas?
📖 Explanation: A stateless server keeps no session data between requests, so each request carries the information it needs. Any replica can therefore serve any client, which makes load balancing and failover simpler. The trade-off is that state must be passed with requests or stored elsewhere when a service needs it.
Q14. A server handles three clients with an iterative design, and each request takes 4 seconds. Client 3 arrives at the same moment as the others. How long does client 3 wait before its service begins?
📖 Explanation: Clients 1 and 2 are served first, each taking 4 seconds, so client 3 waits seconds before its own 4-second service starts. The sequential nature of the iterative server causes this cumulative waiting, which grows with each queued request.
Q15. A concurrent forking server accepts five clients, forking one child per client, while the parent keeps listening. Including the parent, how many processes exist after all five clients are accepted?
📖 Explanation: The parent remains as the listener, and each of the five accepted clients causes one child to be created. The total is processes. Forgetting the parent or counting the clients as processes gives the incorrect values in the other options.
Q16. In a request-reply exchange, the network round trip takes 40 ms and the server processing takes 10 ms. What is the total time from sending the request until the reply is received?
📖 Explanation: The request travels to the server and the reply returns, which is the 40 ms round trip, and the server spends 10 ms processing the request. The total response time is ms. Adding the processing time to the network time, rather than using only one of them, gives the full picture.
Q17. Which sequence of calls correctly describes the steps a client takes to use a connection-oriented service?
📖 Explanation: The client first creates a socket, then connects to the server's address, exchanges data with send and receive, and finally closes the connection. The server uses listen and accept instead of connect, so the other sequences mix up the client and server roles or place steps in the wrong order.
Q18. Which call must a server make before it can call accept on a connection-oriented socket?
📖 Explanation: The listen call prepares the socket to queue incoming connection requests, and accept can only remove requests from that queue. Calling accept without listen is not valid for a connection-oriented server, so listen is an essential step in the server's sequence of setup calls.
Q19. A server takes 100 ms to process each request and has one worker, so its throughput is 10 requests per second. With four workers working in parallel and no contention, what throughput would you expect?
📖 Explanation: Each worker completes requests per second, so four workers provide requests per second under ideal conditions. The assumption of no contention is important, since shared resources often limit real gains below the ideal value.
Q20. A client wants a remote function add(2, 3) to be executed using RPC. Which step occurs first?
📖 Explanation: The client-side stub packs the arguments into a message before sending it, since the server cannot begin until it receives the request. The result path, where the server returns a reply, occurs later. Following the order of marshalling, transmission, execution and reply is key to understanding how RPC hides the network.
Q21. A student says that once a server accepts a connection, the listening socket must be closed. What is the error?
📖 Explanation: Accept creates a new connected socket for the client and leaves the listening socket in place to keep handling new requests. Closing the listener after the first accept would prevent the server from serving any other client, which would defeat the purpose of a server.
Q22. A student says that TCP preserves message boundaries, so each send always matches exactly one receive. What is the flaw?
📖 Explanation: Because TCP is a stream protocol, the receiver must frame messages itself, for example with length prefixes or delimiters. Assuming that one send equals one receive leads to parsing errors when data arrives in pieces or merged together, which is a common bug in networked programs.
Q23. A student says that the client must know the server's internal implementation to make a remote call. What is the correction?
📖 Explanation: The interface describes what a remote procedure does and what it accepts and returns, while the implementation stays hidden on the server. Stubs use the interface to marshal data, so clients can call remote services without knowing how they are built internally, which supports independent evolution of the two sides.
Q24. A student says that RPC calls always execute on the local machine because the stub hides the network. What is wrong with this reasoning?
📖 Explanation: The stub gives a local-looking interface, but the actual work happens on the remote machine. The student conflates the appearance of a local call with where execution occurs. Remembering that marshalling carries the request to the remote site is essential for understanding the model, including its failure modes.
Q25. A student says that a concurrent forking server is always faster, so an iterative server is never useful. Which evaluation is most accurate?
📖 Explanation: Creating a process has overhead, and for very short requests the cost of forking can exceed the time spent serving the request. An iterative design avoids this overhead and may be adequate for light, fast workloads. The student's universal claim ignores this design trade-off.
Q26. A graph compares average response times for 10 clients: iterative design 50 ms and concurrent design 12 ms. What is the best inference?
📖 Explanation: The concurrent design's average of 12 ms is much lower than the iterative design's 50 ms, showing that overlapping requests reduces waiting for clients. The inference is specific to this measured workload, but it supports the value of concurrency under similar conditions.
Q27. A graph shows throughput against the number of clients. The iterative design stays flat at 10 requests per second, while the concurrent design rises and then plateaus at about 40 requests per second. What does this suggest?
📖 Explanation: The concurrent design's rise shows that serving requests in parallel increases total throughput, while its plateau indicates that a resource such as CPU or network becomes the limit. The flat iterative line shows no benefit from additional clients, which matches its one-at-a-time nature.
Q28. A graph shows the number of pending connections in a server's backlog rising to a limit and then new connection attempts being refused. What does this indicate?
📖 Explanation: When pending connections reach the backlog limit, further attempts are refused because there is no room to hold them. This signals that arrivals exceed the server's accept rate, which is the defining symptom of overload. Diagnosing it may require more workers or capacity.
Q29. A graph plots average latency against server load. Latency stays low at light load, then rises sharply as the load approaches capacity. What is the best inference?
📖 Explanation: At low load, requests rarely wait, so latency stays close to the service time. As load approaches capacity, requests spend more time queued, and latency rises steeply. The non-linear shape is the typical signature of queueing behaviour in a client-server system.
Q30. Which combination best describes a remote procedure call that blocks the caller until the reply arrives?
📖 Explanation: A synchronous RPC blocks the client until the server's reply returns, which matches the description. The asynchronous option delivers no result, the local call involves no network, and shared memory copying has no reply, so only the first option captures a blocking remote call accurately.
Q31. Which pairing correctly matches a socket operation with its role?
📖 Explanation: A client calls connect to start a connection to the server's address. Accept belongs to the server and takes a pending connection from the queue, listen prepares the server to receive requests, and bind assigns the address. The other pairings swap these roles, so they are inaccurate.
Q32. A connection-oriented server uses a thread pool with a fixed number of workers and a single listening socket. Which combination describes this design correctly?
📖 Explanation: A thread pool with bounded workers serves connections accepted from a single listening socket, which makes it a concurrent server with limited concurrency. The other options describe different architectures, such as iterative designs, peer-to-peer broadcast or shared memory, that do not match the stated combination of listener, pool and connections.
Q33. A server can process requests at a combined rate of 50 per second in total capacity. Requests arrive at 200 per second. What is the server's utilization, expressed as arrivals divided by capacity?
📖 Explanation: Utilization is the ratio of arrival rate to capacity, here , or 400 percent. A value above 100 percent means the server cannot keep up, and queues grow without bound, which is why capacity planning must ensure arrivals stay below the service rate.
Q34. A client connects to a server, which takes one round-trip time of 50 ms to establish the connection. The client then sends a request and receives the reply after another round trip of 50 ms, ignoring processing time. How long does the client wait from starting the connection until the reply arrives?
📖 Explanation: Connection establishment takes one round trip of 50 ms, and the request and reply take a second round trip of 50 ms. The total is ms. Counting each round trip separately, and not merging them, is the key step in this multi-step timing problem.
Q35. Why are idempotent operations easier to retry after a timeout in a request-reply protocol?
📖 Explanation: When a reply is lost, the client cannot tell whether the server executed the request. If the operation is idempotent, executing it again produces the same result, so the retry is safe. Non-idempotent operations, such as charging an account twice, need extra safeguards, so this property is central to reliable client-server design.