Answer to Question #193006 in Algorithms for Jean Claude

Question #193006

Using the Win32 API, write a system program to create a process with a single thread as follows: 

a)     The process should be used to execute an existing program.

b)     After successful running of the process, display the process ID and thread ID. 

c)     Compile and run the program.

d)     Create a zip of the project/program folder and upload.


1
Expert's answer
2021-05-17T04:29:35-0400

(a) Fork system call is used for creating a new process, which is called child process, which runs concurrently with the process that makes the fork() call (parent process).

  1. After a new child process is created, both processes will execute the next instruction following the fork() system call.

(b) A child process uses the same pc(program counter), same CPU registers, same open files which use in the parent process.

  1. It takes no parameters and returns an integer value. Below are different values returned by fork().
  2. Negative Value: creation of a child process was unsuccessful.


(c) #include <stdio.h>

#include <sys/types.h>

#include <unistd.h>

int main()

{

  
fork();

printf("Hello world!\n");

return 0;

}

Output:

Hello world!

Hello world!

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS