Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int N;
pid_t pid;
int cont;
if (argc != 2) {
printf("Wrong number of command-line parameters!\n");
return 1;
}
N = atoi(argv[1]);
printf("Creating process sequence of length %d.\n",N);
printf("%d begins the sequence.\n",getpid());
/* What I have to do next ?????? */
}
No Answer is Posted For this Question
Be the First to Post Answer
What is s or c?
What are dangling pointers in c?
Difference between strcpy() and memcpy() function?
What compilation do?
7 Answers Geometric Software, Infosys,
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less.
To what value are pointers initialized? 1) NULL 2) Newly allocated memory 3) No action is taken by the compiler to initialize pointers.
What is the process of writing the null pointer?
write a program to display reverse of a number using for loop?
Do you know the difference between malloc() and calloc() function?
34.what are bitwise shift operators? 35.what are bit fields? What is the use of bit fields in a structure declaration? 36.what is the size of an integer variable? 37.what are the files which are automatically opened when a c file is executed? 38.what is the little endian and big endian? 39.what is the use of fflush() function? 40.what is the difference between exit() and _exit() functions? 41.where does malloc() function get the memory? 42.what is the difference between malloc() and calloc() function? 43.what is the difference between postfix and prefix unary increment operators?
Define function ?Explain about arguments?
2 Answers Geometric Software, Infosys,