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
Price of ETH coin right now?<br> Don't answer if u don't know.
zzz [600]

Answer:

58,715.40

Explanation:

5 0
2 years ago
For a certain company, the cost function for producing x items is C(x)=50x+100 and the revenue function for selling x items is R
solmaris [256]

Assuming that this company sells all that it produces, the profit function would be given by P(x) = -0.5(x - 100)² + 5,000 - 50x - 100.

<h3>What is profit?</h3>

In Economics, profit can be defined as a measure of the amount of money (revenue) that is generated when the selling price is deducted from the cost price of a good or service, which is usually provided by producers.

This ultimately implies that, all producers generally work to maximize their profits and make them as large as possible, in order to enable them break even and successful.

Mathematically, the profit function P(x) of a business firm simply refers to the revenue function R(x) minus the cost function C(x):

P(x) = R(x) - C(x)

Where:

  • R(x) represents how much it takes in.
  • C(x) represents how much it spends.

Substituting the given parameters into the formula, we have;

P(x) = -0.5(x - 100)² + 5,000 - (50x + 100)

P(x) = -0.5(x - 100)² + 5,000 - 50x - 100

Read more on maximized profit here: brainly.com/question/13800671

#SPJ1

7 0
2 years ago
Describe network in terms of the class computer lab
kobusy [5.1K]
<span>a group or system of interconnected people or things</span>
6 0
3 years ago
What are specific and relevant terms that will help you locate information using an internet search engine?
Liono4ka [1.6K]
I would say A:keywords

Hope this helps

I’m sorry if this is wrong

Have a great day/night
3 0
2 years ago
Explain<br> the three types of periodic<br>maintanance. .​
LenaWriter [7]

Answer:

poop i think

Explanation:

6 0
3 years ago
Other questions:
  • Explain the function of the Ribbon in Microsoft Word.
    15·1 answer
  • You receive $50 as a birthday gift and choose to spend it all on new wallpaper for your room. The opportunity cost of this decis
    7·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • Mobile apps known as news _________ collect articles from a variety of sources and present them to you in a magazine-style forma
    7·2 answers
  • When planning a presentation, there are several factors you need to consider. Which of the following is one factor you should co
    8·1 answer
  • Technician A says that PTC heaters can be built into a conventional heater core assembly. Technician B says that a PTC heater's
    11·1 answer
  • A _____ refers to a product or service, such as a technical report, a training session, a piece of hardware, or a segment of sof
    12·2 answers
  • Meaning of ‘integrity of data’
    14·2 answers
  • Read the scenario and then answer the question using only the information provided.
    7·1 answer
  • Write a program that reads a file that contains only integers, but some of the integers have embedded commas, as in 145,020. The
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!