0% found this document useful (0 votes)
58 views2 pages

Assignment 1

This document contains 5 questions about processes, forking, and sockets in C and Java: 1. It asks how many new processes will result from a series of fork() calls. 2. It asks to explain the output at a specific line of code. 3. It asks to write a C program that uses fork() to generate the Fibonacci sequence in the child process based on a command line argument. 4. It asks to write a Java program to create a server that continuously sends the date and time to clients that connect. 5. It asks to write a Java program illustrating server socket creation, waiting for a client request, and responding by greeting the client.

Uploaded by

gutterbc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views2 pages

Assignment 1

This document contains 5 questions about processes, forking, and sockets in C and Java: 1. It asks how many new processes will result from a series of fork() calls. 2. It asks to explain the output at a specific line of code. 3. It asks to write a C program that uses fork() to generate the Fibonacci sequence in the child process based on a command line argument. 4. It asks to write a Java program to create a server that continuously sends the date and time to clients that connect. 5. It asks to write a Java program illustrating server socket creation, waiting for a client request, and responding by greeting the client.

Uploaded by

gutterbc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 1

1. After a program executes the following series of fork()calls, how many new processes
will result (assuming that none of the calls fails)?

fork();

fork();

fork();

fork()

2. Explain What will be the output at LINE A

3. The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, . Formally, it


can be expressed as:

Fib0 = 0, Fib1 = 1, Fibn = Fibn-1 + Fibn-2 , n >=2

Write a C program using the fork() system call that generates the Fibonacci sequence
in the child process. The number of the sequence will be provided in the command
line. For example, if a 5 is provided, the first five numbers in the Fibonacci sequence
will be output by the child process. Because the parent and child processes have their
own copies of the data, it will be necessary for the child to output the sequence,
without resorting to other techniques. Have the parent invoke the wait() system call
to wait for the child process to complete before exiting the program. Perform
necessary error checking to ensure that a non-negative number is passed on the
command line.

4. Write a JAVA program to create a server that continuously runs and sends the date and
time as soon as a client connects to it.
5. Write a JAVA program illustrating creation of a server socket, waiting for client request,
and then responding to a client that requested for connection by greeting it is.

You might also like