Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective The ring of processes program: this program creates a circular singly link list of processes using fork) and pipes. The parent process will: a)

image text in transcribed

Objective The ring of processes program: this program creates a circular singly link list of processes using fork) and pipes. The parent process will: a) prompt the user for the hostname and port of the server program; b) send the request about the size of the ring to the server program; c) create the ring of processes (the id of the processes starts from 0); d) pass the token to the first process in the ring (can be the parent process); and e) Finish the simulation. The parent process must guarantee that all the processes of the ring end before finishing its execution. This assignment ll introduce you to interprocess communications mechanisms in UNIX using pipes and sockets. Specifications You must write two programs to simulate the operation of a token ring network. A token ring network uses the token passing access method, which is based on a small frame called a token that circulates a ring-shaped media in a logical direction when devices are idle. To transmit information, the device must seize the token. This method guarantees that only one device at a time will have access to the network. Each process in the ring must: a) wait for the token (if the token value equals to end of simulation, skip steps b and c); b) connect to the server program to get the access request value (0Network not needed, 1 - Network needed, -1End simulation); c) print the following message "Process n is using the network where n is the process id, if the access request value is equal to 1; and d) pass the token to the next process in the ring. If the access request value is equal to -1 or the token value is equal to end of simulation, the process will finish its execution. The server program: the user will execute this program using the following syntax: Jexec filename port_ no input filename where exec filename is the name of your executable file, port no is the port number to create your socket, and input filename is the name of your input file Implementation This program receives the information about the port number from the command line and reads the information about the size of the ring and the parameters for the simulation from a file using I/O redirection. Given the following input: Input Format: the input file will look like: // Number of processes in the ring Access request from PO in the ring /0 Network not needed / 1 Network needed. -1 The expected output is -1 // End the simulation Process 1 is using the network Process 1 is using the network Process 0 is using the network .The size of the ring is a positive integer value greater than 1 .The number of access requests in the simulation can be from 1 to n, where n can be greater than the size of the ring (the ring is a circular singly linked list HINTS: of processes). Use a single-threaded server to avoid critical sections inside the server Since your server will not fork any child processes, you should not worry about handling zombies and can safely ignore the fireman() call in the primer An access request equal to -1 will end the execution of the simulation. After reading the input file, the server program will create a socket to: a) receive the request from the client program (ring of processes) about the size of the ring; b) send the size of the ring to the client program; and c) answer the request of each process in the ring about the access request value. The server program will finish its execution after sending the access request value -1 (end You can safely assume that the input files will always be in the proper format and that the maximum size of the ring is ten processes. These specifications were written on Friday, October 5, 2018. Please refer to the course web site for corrections and updates. of simulation) to a process in the ring Objective The ring of processes program: this program creates a circular singly link list of processes using fork) and pipes. The parent process will: a) prompt the user for the hostname and port of the server program; b) send the request about the size of the ring to the server program; c) create the ring of processes (the id of the processes starts from 0); d) pass the token to the first process in the ring (can be the parent process); and e) Finish the simulation. The parent process must guarantee that all the processes of the ring end before finishing its execution. This assignment ll introduce you to interprocess communications mechanisms in UNIX using pipes and sockets. Specifications You must write two programs to simulate the operation of a token ring network. A token ring network uses the token passing access method, which is based on a small frame called a token that circulates a ring-shaped media in a logical direction when devices are idle. To transmit information, the device must seize the token. This method guarantees that only one device at a time will have access to the network. Each process in the ring must: a) wait for the token (if the token value equals to end of simulation, skip steps b and c); b) connect to the server program to get the access request value (0Network not needed, 1 - Network needed, -1End simulation); c) print the following message "Process n is using the network where n is the process id, if the access request value is equal to 1; and d) pass the token to the next process in the ring. If the access request value is equal to -1 or the token value is equal to end of simulation, the process will finish its execution. The server program: the user will execute this program using the following syntax: Jexec filename port_ no input filename where exec filename is the name of your executable file, port no is the port number to create your socket, and input filename is the name of your input file Implementation This program receives the information about the port number from the command line and reads the information about the size of the ring and the parameters for the simulation from a file using I/O redirection. Given the following input: Input Format: the input file will look like: // Number of processes in the ring Access request from PO in the ring /0 Network not needed / 1 Network needed. -1 The expected output is -1 // End the simulation Process 1 is using the network Process 1 is using the network Process 0 is using the network .The size of the ring is a positive integer value greater than 1 .The number of access requests in the simulation can be from 1 to n, where n can be greater than the size of the ring (the ring is a circular singly linked list HINTS: of processes). Use a single-threaded server to avoid critical sections inside the server Since your server will not fork any child processes, you should not worry about handling zombies and can safely ignore the fireman() call in the primer An access request equal to -1 will end the execution of the simulation. After reading the input file, the server program will create a socket to: a) receive the request from the client program (ring of processes) about the size of the ring; b) send the size of the ring to the client program; and c) answer the request of each process in the ring about the access request value. The server program will finish its execution after sending the access request value -1 (end You can safely assume that the input files will always be in the proper format and that the maximum size of the ring is ten processes. These specifications were written on Friday, October 5, 2018. Please refer to the course web site for corrections and updates. of simulation) to a process in the ring

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago