Question: CENG328 Operating Systems - Spring 2017 Labwork 6 Apr 03 05, 2017 Question 1 A- Write a program in C which takes 4 CLI arguments
CENG328 Operating Systems - Spring 2017 Labwork 6 Apr 03 05, 2017 Question 1
A- Write a program in C which takes 4 CLI arguments (A, B, C and D) and creates 20 POSIX threads. These threads each are responsible for generating A random numbers between B and C and counting how many of these numbers are evenly divisible by D. These threads are also responsible for writing the numbers that are divisible by D into files named numbers0.txt, numbers1.txt... as well. When these threads are done, main thread must print the results on screen. Sample Run $ ./program1 100000 1000 50000 42 Thread 0 - 2341 Thread 1 - 2419 Thread 2 2325 . . . Thread 17 - 2284 Thread 18 - 2388 Thread 19 - 2284
B- Write a program in C which takes 3 CLI arguments (A, B, and C) and creates 15 POSIX threads. These threads each are responsible for generating A random characters between B and C and keeping count of frequency of letters. These threads are also responsible for writing the characters into files named chars0.txt, chars1.txt... as well. When these threads are done, main thread must print the results on screen. Sample Run $ ./program1 1000 d t Thread 0 59 65 61 72 . . . (d=59, e=65. . .) Thread 1 69 78 65 56 . . . . . . Thread 13 55 67 71 64 . . . Thread 14 70 68 61 49 . . .
C- Write a program in C which takes 5 CLI arguments (A, B, C, D and E) and creates 25 POSIX threads. These threads each are responsible for generating E random integers between A and B. If any of these numbers are evenly divisible by C but not D, the program must keep count of these numbers and write them into files named nums0.txt, nums1.txt, etc. When these threads are done, main thread must print the results on screen. Sample Run $ ./program1 10 100 10 20 500 Thread 0 32 // file contents: 70 30 10 30 90 50 50 . . . Thread 1 24 // file contents: 90 30 30 50 50 50 10 . . . . . . Thread 23 - 34 // file contents: 70 10 10 10 50 90 90 . . . Thread 24 22 // file contents: 50 70 90 30 50 90 50 . . .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
