Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the following Operating System homework questions: 1) If a proc

ID: 3890766 • Letter: I

Question

I need help with the following Operating System homework questions:

1) If a process has been swapped out to disk, what states must it pass through in order to be running?

2)When processes communicate by sockets, what possible port assignments are valid?

3) What aspects of pipes do child processes inherit from their parent in UNIX?

4) How do the child and parent processes know what code they should execute after being forked?

5) Shared memory is better than message passing for what types of OS’s?

Explanation / Answer

2. The possible ports for user written processes are in the range 49152-65535.Port 80 is used for the http server and port 25 for SMTP.Port 0-1023 are generally allocated to server services by the IANA.Ports 1024 to 49151 are reserved ports and generally should be avoided by user code.All the communicating processes must use the same port number.

3. Pipe is a unidirectional communication mechanism between two processes. Data is written at one end and read at the other end.A pipe is generally created using the following system call.

int fd[2];

read_fd = fd[0];

write_fd = fd[1];

Here fd is an two element integer array that contains the read and write file descriptor returned by the successful execution of the pipe system call.These file descriptors are inherited by both the child and parent process and can be used to read or write data to the pipe.

4. The system call fork() is used to create child processes.If fork() returns a negative value, it indicates process creation failed.It returns a 0 to the newly created child process and a positive value, which is, the process ID of the child to the parent process.

Consider the following code section to understand the mechanism.

pid_t pid;

pid = fork();

if (pid == 0)

    ChildProcess(); // call the ChildProcess function in-case this is the child'd memory space

else

    ParentProcess();