Process creation

Assignment Help C/C++ Programming
Reference no: EM131103978

PROCESS CREATION
Write a C (or C++) program that can create a collection of processes (each with its base thread) when a user runs the program. Using the standard cmd prompt features, you can "launch" a process just by typing its name. I will need some way to provide multiple command lines to the program. One way to do this is to create a file with the list of commands that I wish to run. The program would then open the file, read a line from the file and create a process to run the command specified in that line. Repeat until all lines in the file have been read. For example, a line in your file might be like "/bin/pwd". Creating a process to run this command will print out the current working directory. This file name should be passed as an argument to the main program. Your main program fetches each line from the file and creates respective processes. The program uses fork and execve (or some other member of the family of exec system calls).

Output:
******************** START ***************************
line is 9 long
COMMAND : /bin/pwd
/home/rcotter/cs431/lab2
line is 16 long
COMMAND : /usr/bin/whoami
rcotter
line is 8 long
COMMAND : /bin/df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_kcsce450p2-lv_root
74663088 68578252 2292148 97% /
tmpfs 508056 812 507244 1% /dev/shm
/dev/sda1 198337 61827 126270 33% /boot
line is 10 long
COMMAND : /bin/date
Wed Sep 21 10:49:36 CDT 2011
******************* END ******************************
Second:
THREAD CREATION
Write a C (or C++) program that creates multiple threads, and then terminates after a specified interval. Each of these threads executes a predefined work function. Threads can be created by using the pthread_create system call. The number of threads to be created and a run time are passed as command line arguments. (For example "mythread 3 15" would create 3 threads and keep running for 15 seconds.) The output of each newly created thread should display the number of the thread that is executing the function. (For this, you will need to pass the thread number to the new thread through pthread_create( ) function.)
Sample output:
Loop 0 of thread 1 work cycle
Just created thread 3070872432
Loop 0 of thread 2 work cycle
Just created thread 3062479728
Loop 0 of thread 3 work cycle
Just created thread 3054087024
The Time Is Now: Wed Sep 21 11:12:20

Loop 9 of thread 1 work cycle
Loop 9 of thread 2 work cycle
Loop 9 of thread 3 work cycle
The Time Is Now: Wed Sep 21 11:12:29 2011

The Time Is Now: Wed Sep 21 11:12:29 2011

Timer Complete

Reference no: EM131103978

Questions Cloud

Proposed research methodology : Discuss how the research will be executed to achieve the proposed research objectives. The methodology should be based on the methods that are used in the research area to conduct the research. The methodology selected must be able to achieve the lis..
Distributing and rationing most government services : 1. How does the mechanism for distributing and rationing most government services differ from that for distributing goods through markets?
Explain risk management and what it means to the cio : Different kinds of personnel are required to staff an IT department depending on their IT strategy. For the two organizations below, identify four IT positions that are most important in each organization and why.
Designing global supply chain networks exercise : Unipart, a manufacturer of auto-parts, is considering B2B marketplaces to purchase its MRO supplies. Both marketplaces or for a full line of supplies at very similar prices for products and shipping. Both provide similar service levels and lead t..
Process creation : Write a C (or C++) program that can create a collection of processes (each with its base thread) when a user runs the program. Using the standard cmd prompt features, you can "launch" a process just by typing its name. I will need some way to provide..
Determining the effect on employment : If an increase in wage rates for the low paid led to their being more motivated, how would this affect the marginal revenue product and the demand for such workers? What implications does your answer have for the effect on employment in such cases..
Appear to be a straightforward set of calculations : Although budgeting may appear to be a straightforward set of calculations, there are still many areas in the budgetary process where unethical practices may occur.
Members of the european union : It is just few days after the members of the European Union in the United Kingdom held referendum to determine their membership fate in the unions especially after the great financial crisis that the U.K members have experienced for the previous y..
Association between vaccines and autism : What have you heard about an association between vaccines and autism? What are some of the hypotheses you have heard about or read about - What types of studies would you recommend to look at an association between vaccines and autism?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a program that draws a two-dimensional house

Create a program that draws a two-dimensional house seen from the front, the way a child would see it: with a door, two windows, and a roof with a chimney

  Wrie a program that will generate a list of 10000 numbers

Wrie a program that will generate a list of 10000 numbers stored in an array with values 1 and 500.Print out any original 200 numbers to show the results(not one number per line either).Now sort the number using bubble sort

  Make a class employee with a name and salary

Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type string. Supply a method to tostring that prints the manager's name, Department and salary.

  The limit on the amount of wage income

If the government raised the limit on the amount of wage income that is subject to the F.I.C.A. tax, this would: A. Move the Lorenz curve further from the line of income equality  B. Have no effect on the Lorenz curve

  Boolean expressions with while loops

These questions explore using boolean expressions with while loops. If you get confused by the output as you work through these questions, you should review those pages in your textbook, with special attention to the operators &&, ||, and !

  Process the image provided originally with assignment

Download the latest trial version of FTK 1.8.?. Find it under support/downloads at http://www.accessdata.org. Use it to process the image provided originally with Assignment 2. Find the pictures of weasels and create a bookmark containing all of ..

  Write a recursive function that takes a string as parameter

Write a recursive function that takes a string as a parameter and prints its reversal in the same function in c++

  Optimize the preceding code for kathy

Optimize the preceding code for Kathy and find out the errors (if any). What would be the output of the preceding code, if the first number is 46 while the second number is 37?

  C++ is not case sensitive

C++ is not case sensitive, Declarations can be placed anywhere in the program, Statement and declarations must end with a semicolon

  Program that will output the solution to the quadratic eq

Create a C++ program that will output the solution to the quadratic equation for any range of integer coefficients

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Programmingto compute the volume of water in the cubic feet

Write down an algorithm (Programming in C) in order to compute the volume of water in the cubic feet, flowing through a pipe of diameter d in feet, having a velocity of v feet per second.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd