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
Why do we need the system requirements for Adobe photoshop?
babymother [125]
I’m sorry and I do not know I just need credits thank have a nice day
7 0
3 years ago
Programmers can use sql on systems ranging from pcs to mid-size servers.
zaharov [31]

It is false that Programmers can use SQL on systems ranging from PCs to mid-size servers.

Applications for structured query language can be found in a wide range of sectors, mostly in those that deal with database-related tasks. It might be used, for example, by a data analyst to query data sets and produce precise insights. On the other hand, a data scientist might use this programming language to add data to their models.

Businesses and other organizations use SQL tools to create and modify new tables as well as access and edit information and data in their databases.

A database is a tool for gathering and organizing data. Databases can store data about people, things, orders, and other things. Many databases begin in a spreadsheet or word processor. Many firms find it beneficial to move them to a database made by a database management system as they grow larger.

SQL helps manage the data kept in databases, enabling users to get the precise data they require when they need it.

To learn more about SQL click here:

brainly.com/question/13154090

#SPJ4

4 0
11 months ago
Why do you feel an organization has multiple layers of security in place to protect its operation?
aalyn [17]

The purpose of including multiple layers in your network security<span> is to make sure that </span>each single defense component has a backup<span> in the case of a flaw or missing coverage. The individual strengths of each layer also cover any gaps that other defenses may lack.</span>

With this assumption in mind, each individual layer in a multi-layered security approach focuses on a specific area where the malware could attack. By working in concert, these layers of security offer a better chance of stopping intruders from breaching company networks than using a single solution.

The types of security layers you can use in your network defense include:

<span>Web protectionPatch managementEmail security and archivingVulnerability assessment and analyticsAntivirus softwareData encryptionFirewallsDigital certificatesAnti-spam and spam filtersPrivacy controls</span>

<span>Having multiple layers of security in place is crucial for MSPs who protect data at all levels and across numerous applications and devices. Not only should data stay safe, but so should the methods of communication and the network where information is transferred.</span>

4 0
3 years ago
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
3 years ago
What is a computer ?it types​
Keith_Richards [23]
Um can you be more descriptive
8 0
3 years ago
Read 2 more answers
Other questions:
  • Write two statements to read in values for birthMonth followed by birthYear, separated by a space. Write a statement to print th
    12·1 answer
  • A(n) ____________ is a program that translates a high-level language program into a separate machine language program.
    7·1 answer
  • The two ways to use the help menu is by searching of the contents or searching the _____
    13·2 answers
  • Which group on the Home Tab allows you to add shapes to a PowerPoint slide?
    9·2 answers
  • Which of the following TCP/IP settings should be configured to specify DNS suffixes to use other than resolving names through a
    9·1 answer
  • Type the correct answer in each box. Spell all words correctly.
    14·2 answers
  • Cindy tried to delete a customer but the customer still had open invoices so the system would not allow her to delete the custom
    11·1 answer
  • Can you please look through this code and see wants wrong with it? its in python
    11·1 answer
  • The software concept ___________and defines a need for the new system.
    6·1 answer
  • Name various input and output devices used with computers.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!