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
Object Material: metal or non-metal? Prediction: Will the light bulb light up? Morm Observation: Does the light bulb light up? n
Mandarinka [93]

Answer:

it would be nail key

Explanation

mainly cuz i went to college ad it makes sense ause mettal and metal yw:)

4 0
3 years ago
What is the best web browser to use?
tiny-mole [99]
That would depend on what you would like to get out of your experience with the web broswer. Google chrome offers more efficient computational algorhythms, a quicker navigation of the UI, but loses privacy due to the connected google services which can report your data usage if not properly configured.Browsers like firefox offer extension capability (the same as google chrome) and is open sourced, but may be slower to navigate depending on user to user experience.Other browsers i would avoid unless they are: TOR (which is still just a heavily modified and secured version of firefox).
6 0
3 years ago
Read 2 more answers
DOS was the most common operating system for Microsoft-based computers before the introduction of Windows. DOS required the user
vaieri [72.5K]

Answer:

Windows has GUI, where its predecessor DOS does not.

Explanation:

DOS required the user to type instructions into the computer through an interface system known as command line.

Windows has graphical user Interface (GUI), that allows commands in a more user friendly environment than DOS.

4 0
3 years ago
When malicious code is planted on your computer and alters your browser's ability to find web addresses, it is known as ________
tresset_1 [31]
The answer is Phishing
3 0
4 years ago
Read 2 more answers
(n) ________ is a device that enables members of a local network to access the network while keeping nonmembers out of the netwo
rosijanka [135]
The answer is A. Firewall
4 0
4 years ago
Other questions:
  • Unlike a virtual image, a real image
    7·1 answer
  • Can anyone guide me on what to learn after C language?
    15·1 answer
  • Which of the following statements is correct? A. The columns will be listed in the results in the same order they are stored in
    7·1 answer
  • Someone please help fast! I’m taking the test rn and I don’t understand this!!!!!!
    15·1 answer
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    13·1 answer
  • This question is related to linked-list representation of disjoint sets. Consider two sets Sx and Sy that have 3 and 5 elements,
    14·1 answer
  • Macro mode is used to take landscape photographs of subjects fairly far from the camera.
    12·2 answers
  • Python 3 please hurry!!
    14·1 answer
  • Question 1 of 10
    8·1 answer
  • Identify the true statements about the approach to privacy around the world. a. Uncertainty concerning the nature, extent, and v
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!