Question: CENG328 Operating Systems - Spring 2017 Labwork 5 Mar 20 22, 2017 Question 1 A Write a program in C which creates 5 POSIX threads.

CENG328 Operating Systems - Spring 2017 Labwork 5 Mar 20 22, 2017 Question 1

A Write a program in C which creates 5 POSIX threads. These threads must individually generate arrays of 2.000 random integers between 0 and 50.000 (inclusive) and classify these integers according to their number of digits. Sample Run $ ./program1 Thread 0: 1-9: 0, 10-99: 7, 100-999: 34, 1000-9999: 358, 10000-99999: 1601 Thread 2: 1-9: 0, 10-99: 5, 100-999: 38, 1000-9999: 366, 10000-99999: 1591 Thread 3: 1-9: 0, 10-99: 2, 100-999: 35, 1000-9999: 373, 10000-99999: 1590 Thread 1: 1-9: 0, 10-99: 2, 100-999: 24, 1000-9999: 356, 10000-99999: 1618 Thread 5: 1-9: 1, 10-99: 5, 100-999: 45, 1000-9999: 346, 10000-99999: 1603 Question 2 Now alter the program in Question 1, such that now the main thread creates and fills a single array of 10.000 random integers and each thread gets one fifth of this array (instead of generating their individual arrays).

B Write a program in C which creates 10 POSIX threads. These threads must individually generate arrays of 5.000 random lowercase characters (a-z) and count number of vowel and consonant characters. Sample Run $ ./program1 Thread 140026609727232: Vowels: 364, consonants: 4636 Thread 140026601334528: Vowels: 370, consonants: 4630 Thread 140026592941824: Vowels: 386, consonants: 4614 Thread 140026584549120: Vowels: 406, consonants: 4594 Thread 140026576156416: Vowels: 395, consonants: 4605 Thread 140026567763712: Vowels: 385, consonants: 4615 Thread 140026550978304: Vowels: 403, consonants: 4597 Thread 140026534192896: Vowels: 430, consonants: 4570 Thread 140026542585600: Vowels: 416, consonants: 4584 Thread 140026559371008: Vowels: 385, consonants: 4615 Question 2 Now alter the program in Question 1, such that now the main thread creates and fills a single array of 50.000 random characters and each thread

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!