Skip to content

Instantly share code, notes, and snippets.

@easauceda
Last active January 25, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easauceda/5f13781186d21d034ee2 to your computer and use it in GitHub Desktop.
Save easauceda/5f13781186d21d034ee2 to your computer and use it in GitHub Desktop.
Homework Two Assignment

#Homework Two

1.

Create a child process. The child process generates a random number n between 1 ~ 10, outputs n and it's process ID. The parent process waits for the child process and outputs n. (Use pipes to share n between the parent and child)

2.

Write a program to implement the following: Simulate a bank account containing a savings account and checking account. The user inputs a number n, which is the total number of clients. Each client transfers $10 from the checking account to the savings account. Create a child process for each client. Use shared memory to simulate shared accounts.

3.

Write a program that takes two inputs, a & b from the user. Create two threads, the first will output the sum of i, incremented by one from a to b. The other outputs a * (a + 1) * (a + 2) .... b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment