Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When compiling and running the following program, select which of the following statement (s) is true? #include #include #include #include #include #include #include #include int

When compiling and running the following program, select which of the following statement (s) is true?

#include  #include  #include  #include  #include  #include  #include  #include  int id; struct Mesg{ char message[40]; int count; char token[10][20]; char sorttoken[10][20]; }; #define KEY ((key_t)(713)) #define SEGSIZE sizeof(struct Mesg) void cleanup(int sigtype){ shmdt(0); printf(" Terminating "); execlp("ipcrm","ipcrm","-M","713",(char*)(0)); printf("ERROR!"); exit(0); } int main(int argc, char *argv[]){ int i,j; int count; char *token; char tmp[20]; struct Mesg *msg; struct shmid_ds shmbuf; signal(SIGINT,cleanup); signal(SIGQUIT,cleanup); id=shmget(KEY,SEGSIZE,IPC_CREAT|0666); if(idcount=0; strcpy(msg->message, "Welcome to COEN 177 Operating Systems"); count = strlen(msg->message); if(fork()==0){ msg->count=1; for(i=0;imessage[i]==' ') msg->count++; exit(0); } else if(fork()==0){ i=0; token=strtok(msg->message," "); while(token!=NULL){ strcpy(msg->token[i],token); i++; token=strtok(NULL," "); } exit(0); }else if(fork()==0){ for(i=0;icount;i++){ strcpy(tmp,msg->token[i]); strcpy(msg->sorttoken[i],tmp); } for(i=msg->count-1;i>=0;i--){ for(j=0;jsorttoken[j],msg->sorttoken[j+1])>0){ strcpy(tmp,msg->sorttoken[j]); strcpy(msg->sorttoken[j],msg->sorttoken[j+1]); strcpy(msg->sorttoken[j+1],tmp); } } } for(i=0;icount;i++){ printf("%s ",msg->sorttoken[i]); } exit(0); } for(i=0;i 

image text in transcribed

The number of processing that will be running is equal to 4 The output of the program is: 177 COEN Operating Systems Welcome to The output of the program is: 177 The number of processing that will be running is equal to 8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions