Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
ECSE 427/COMP 310 – Operating Systems Assignment 01 – Simple RPC Service Check My Courses for Due Date High-Level Description Consider a simple calculator. It has a read-eval-print-loop (REPL), where you enter something like the following. The calculator is structured as two programs: frontend and backend. The frontend does not do the actual calculations. It just prints the prompt, get the input from the user, parses the input into a message. The frontend passes the message to the backend that does the actual calculations and passes the result back to the frontend, where it is printed to the user. We write two programs backend.c and frontend.c. The backend has some functions it wants to expose for the frontend. The frontend needs to call those functions that are exposed by the backend. The remote procedure call service (RPCServ) is responsible for linking the two. You are expected to develop such a RPCServ as part of this assignment. We start with a very simple implementation. The frontend issues an execution command and backend runs it and returns the result. This simple structure would work even with multiple frontends if the commands issued by the frontends can be executed very quickly. If some commands can hold the backend for a long time (like seconds), we have a problem. When a frontend is running a long command, other frontends will find the backend unavailable. That is, you run sleep 5 in the frontend and the backend is held by that frontend for 5 seconds. If other frontends try to run a calculation, they will not get any results. To solve this problem, you will use multi-processing. That is the backend will create a serving process for each frontend. In this configuration, as soon as the frontend connects to the backend, we create a new serving process that is dedicated to the frontend and let it serve the frontend’s requests. Even if the frontend does a sleep 5, it would not cause problems for other frontends. The backend is still available for requests from other frontends. To keep things simple, we limit the number of concurrent frontends to 5. Frontend Requirements The pseudo code shown below for the frontend is not complete. It shows the bare essentials. You need to add the missing functions to make the frontend meet all the requirements and make it work with RPCServ and the backend. backend = RPC_Connect(backendIP, backendPort) while(no_exit) { print_prompt() line = read_line() cmd = parse_line(line) RPC_Call(backend, cmd.name, cmd.args) } RPC_Close(backend) The frontend does not implement any of the commands the user enters into the shell. It simply relays them to the backend. You will notice that the command entered by the user looks like the following: command (string) and parameters. We will restrict the parameters to 2 or less. You can have commands with no parameters. The parameters can be integers or floating-point numbers. You need to have an RPCServ interface to send the command and parameters to the backend. In the pseudo code, we show such an interface – RPC_Call(). The frontend will check if the user has entered the exit command. If that is the case, the frontend will stop reading the next command and terminate the association with the backend. The backend is a separate process, so it keeps running even after the frontend has stopped running. The user can enter the shutdown command in the frontend to terminate the backend. With multiple frontends connecting to the backend, the shutdown can be tricky. More on this in the backend requirements. Some commands entered by the user in the frontend may not be recognized by the backend, in that case the backend will send the NOT_FOUND error message. The front needs to display this to the user. We can also have error message for certain operations such as division by zero errors. These error messages need to be displayed as well.