1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
inessss [21]
3 years ago
7

Write a program that accepts a phrase of unspecified length on the command line. For example: prompt% letter print Operating Sys

tems Class at Kent-State The main0 in this program has to create two threads running functions (vow and cons). The threads should take turns printing the respective words of the phrase supplied on the command line. The vow thread should print all the words that start with a vowel and the cons thread should print all words starting with a consonant. Note that the main thread (running main0) should not print anything itself-the output should be supplied by the threads that it creates. The order of words in the phrase should not be changed in the printout. Your program should work for any phrase of any reasonable length, not just the one given in the example. The output of your program should looks similar to the following prompt% letter print Operating Systems Class at Kent-State vow: Operating cons: Systems cons: Class vow: at cons: Kent-State In this part you are not allowed to use synchronization primitives such as mutexes for thread coordination. You can use sched yield0 to relinquish control of the CPU

Computers and Technology
1 answer:
Sedaia [141]3 years ago
3 0

Answer:

Check the explanation

Explanation:

#define _MULTI_THREADED

#include <pthread.h>

#include <stdio.h>

#include <errno.h>

#define           THREADS          2

int               i=1,j,k,l;

int argcG;

char *argvG[1000];

void *threadfunc(void *parm)

{

int *num;

num=(int*)parm;

while(1)

   {

   if(i>=argcG)

   break;

   if(*num ==1)

   if(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u')

   {

   printf("%s\n",argvG[i]);

   i++;

   continue;

   }

    if(*num ==2)

   if(!(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u'))

   {

   printf("%s\n",argvG[i]);

   i++;

   continue;

   }

   sched_yield();

   }

return NULL;

}

int main(int argc, char *argv[])

{

pthread_t            threadid[THREADS];

int                  rc=0;

int                  loop=0;

int arr[2]={1,2};

argcG=argc;

for(rc=0;rc<argc;rc++)

argvG[rc]=argv[rc];

printf("Creating %d threads\n", THREADS);

for (loop=0; loop<THREADS; ++loop) {

     rc =pthread_create(&threadid[loop], NULL, threadfunc,&arr[loop]);

}

for (loop=0; loop<THREADS; ++loop) {

   rc = pthread_join(threadid[loop], NULL);

}

printf("Main completed\n");

return 0;

}

The below attached image is a sample output

You might be interested in
Directions: Give the shortcut key for the following commands: 1. Open 2. Save 3. New document 4. Copy 5. Undo 6. Redo 7. Paste 8
stepan [7]

Answer:

Explanation:

1 : Ctrl + X

2 Ctrl + C

3 Ctrl + L

4 Ctrl + V

5 Ctrl + B

6 Ctrl + R

7 Ctrl + I

8 Ctrl + E

9 Ctrl + U

10 Ctrl + Z

11 Ctrl + Y

12 Ctrl + N

End

13 Ctrl + A

Home

14 Ctrl + J

15 Ctrl + 2

16 Ctrl + S

17 Ctrl + 1

18 F12

19 Ctrl + W

-----------

20 Ctrl + K

21 Ctrl + ]

22 Ctrl + (left arrow)

23 Ctrl + (right arrow)

24 Ctrl + [

25 Ctrl + Del

26 Ctrl + 5

27 F1                                                         pls mark me as brainliest and              

                                                                   check all the short cuts

8 0
3 years ago
A structure is private by default, but can be declared to be friend or private.
posledela
Structures can be accessed from anywhere within the module or class in which they are declared. A structure is Friend by default. To specify the accessibility in more detail, include Public, Protected, Friend, Protected Friend, or Private in the Structure statement. You must declare every data member of a structure.
4 0
3 years ago
What does a shutter speed of 1 mean
Kruka [31]
<span>Slow shutter speeds allow more light into the camera sensor and are used for low-light and night photography, while fast shutter speeds help to freeze motion. Examples of shutter speeds: 1/15 (1/15th of a second), 1/30, 1/60, 1/125. Aperture – a hole within a lens, through which light travels into the camera body.
Hope this helps : )
</span>
8 0
3 years ago
Read 2 more answers
What are some advantages and disadvantages of streaming and downloading?
stepladder [879]

Answer:

Pro Cons

It is possible to download legitimate music files that do not include DRM and so makes it easier for you to listen to your tracks on different devices. The file may include DRM protection that you were not expecting when you joined the service. Read the fine print.

Explanation:

7 0
3 years ago
What are the benefits of open source software? Risks?
andrezito [222]

Answer:

more security

fewer bugs and faster fixes

no upgrade pushes

low coast

excellent support

as far as the risk part of it. I think that would be

the risk of license restriction, infringement.

5 0
3 years ago
Other questions:
  • 6. When should you return to the right lane after passing another car on the left?
    14·2 answers
  • After typing “application letter” in the Search window in the New dialog box, Nate clicks the Education category. Three letters
    9·1 answer
  • A(n) _____ is a computer network that uses Internet Protocol technology to share information, operational systems, or computing
    12·1 answer
  • A switch is closed, and a lamp turns on.The switch is opened, the lamp turns off. eXplain what is meant by these two statements.
    10·1 answer
  • Please help ASAP, will mark brainliest!
    10·1 answer
  • Witch of the following is a malicious program that can replicate and spread from computer to computer?
    13·1 answer
  • In 5-10 sentences, describe how computer networks work.
    6·1 answer
  • Write a computer program that computes the duration of a projectile’s flight and its height above the ground when it reaches the
    11·1 answer
  • Consider the following code segment.
    11·1 answer
  • How would I copy this image?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!