Question: An office management platform executes its log in process first. Upon its execution log in creates a message queue of structure: struct msg { long
An office management platform executes its log in process first. Upon its execution log in creates a message queue of structure:
struct msg
long int type;
char txt;
;
The process takes input from an user about hisher workspace name. If the workspace is not cse then it prints Invalid workspace name If the workspace name is cse then it writes the name of the workspace in txt and sets the type of message queue using a positive integer and prints about its written message in the queue. Then the process gets interrupted, and another process denoted as otp generator which is a child process of log in starts running.
Otp generator reads the first message with the type set by its parent process and prints its read message from the queue. Then it generates its own process id as otp and stores it in txt and sets a different type in the message queue and prints about its stored message in the queue. The destination of this message is log in process.
Otp generator again sends the same message to another process mail which is its child process but this time by assigning a different type. Then it prints the message which is being sent to process mail. Then it gets interrupted, and its child process mail starts running.
Process mail reads the first message with the type set by its parent process and prints its received message from the queue. It then writes the same message which was read by it in the queue and sends it to process log in by setting a different type and prints about its sent message. Then it terminates and its parent otp generator continues executing and it terminates as well.
After the termination of its child, log in continues running and immediately receives the message sent from its child process from the message queue using the mechanism of reading first message with the same type which was set by otp generator during sending the message and after reading, the process prints the message.
Then log in again reads the message sent from mail by using the mechanism of reading first message with the same type which was set by mail and prints the message after reading as well.
Lastly, log in compares messages received from otp generator and mail. If both messages are the same, it prints OTP Verified Otherwise, it prints OTP Incorrect Then it terminates by removing the message queue.
Provide a proper solution by executing three cooperating processes according to the flow of processes described in the scenario given above, ensuring proper communication between processes using message queue. OTP will be different for every execution as every time a process gets executed it is assigned a new id
Sample Output in the Terminal:
Execution Command in Terminal: p
Please enter the workspace name:
cse
Workspace name sent to otp generator from log in: cse
OTP generator received workspace name from log in: cse
OTP sent to log in from OTP generator:
OTP sent to mail from OTP generator:
Mail received OTP from OTP generator:
OTP sent to log in from mail:
Log in received OTP from OTP generator:
Log in received OTP from mail:
OTP Verified
Execution Command in Terminal: p
Please enter the workspace name:
abc
Invalid workspace name
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
