Question

Which system call should you use to create get the child process’ exit status? What do...

  1. Which system call should you use to create get the child process’ exit status?
  1. What do operating systems use to allow multiple processes load from and store to the same address without interfering with each other?

Homework Answers

Answer #1

System Call :

A system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls.

Services Provided by System Calls :

1. Process creation and management

2. Main memory management

3. File Access, Directory and File system management

4. Device handling(I/O)

5. Protection

6. Networking, etc.

Types of System Calls : There are 5 different categories of system calls –

1. Process control: end, abort, create, terminate, allocate and free memory.

2. File management: create, open, close, delete, read file etc.

3. Device management

4. Information maintenance

5. Communication

System call use to create get the child process exit status :

It is known that fork() system call is used to create a new process which becomes child of the caller process.
Upon exit, the child leaves an exit status that should be returned to the parent. So, when the child finishes it becomes a zombie.

Whenever the child exits or stops, the parent is sent a SIGCHLD signal.
The parent can use the system call wait() or waitpid() along with the macros WIFEXITED and WEXITSTATUS with it to learn about the status of its stopped child.

// C code to find the exit status of child process

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/wait.h>

  

// Driver code

int main(void)

{

    pid_t pid = fork();

      

    if ( pid == 0 )

    {

       /* The pathname of the file passed to execl()

          is not defined   */

       execl("/bin/sh", "bin/sh", "-c", "./nopath", "NULL");

    }

  

    int status;

      

    waitpid(pid, &status, 0);

  

    if ( WIFEXITED(status) )

    {

        int exit_status = WEXITSTATUS(status);        

        printf("Exit status of the child was %d\n",

                                     exit_status);

    }

    return 0;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following program calls the fork() system call to create a child process. Suppose that the...
The following program calls the fork() system call to create a child process. Suppose that the actual pids of the parent process and child process are as follows: Parent process: 801 Child process:   802 (as returned by fork) Assume all supporting libraries have been included. => Use the answer text field to write the values of the pids printed at lines 1, 2, 3, and 4 (indicate each line number and the value printed). int main() {      pid_t pid,...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme. Environment: Unix/Linux environment (VM Linux or Triton...
C++ project The project will allow you to create a system for tracking the games and...
C++ project The project will allow you to create a system for tracking the games and the scores in terms of graphics, story and replay value and will compute the highest score in each category and the highest overall score. The system will allow you to track 5 games in the following arrays: 1) A string array for the game titles 2) An int array for graphics scores from 1 to 5 3) An int array for replay value from...
You have to create a Library Borrowing System based on the following requirements: When new books...
You have to create a Library Borrowing System based on the following requirements: When new books arrive, these books must be cataloged into the system by a librarian (i.e., entered in the system). Information on a book should include book ID, title, author ID, ISBN, and edition. The system should capture author names so that users can search for an author. The library may carry multiple books by the same author, and an author can have multiple books in the...
What characteristics of the market of systems do you think created monopoly market that Microsoft’s operating system enjoyed?
Read the following case study carefully and answer the questions given at the END.Playing Monopoly: MicrosoftThe success of Bill Gates together with his company Microsoft and the most favors Windows computer operating systems that are still dominating the PC operating system market has always been an excellent example stimulating the youths in the It industry to follow. But the business success and seemingly amazing technology innovation should not be very strong reasons why the ethical issues related to Microsoft and...
The goal of this assignment is to implement a simple client-server system. You have to use...
The goal of this assignment is to implement a simple client-server system. You have to use Python. The basic functionality of the system is a remote calculator. You first will be sending expressions through the client to the server. The server will then calculate the result of the expression and send it back to the client where it is displayed. The server should also send back to the client the string "Socket Programming" as many times as the absolute value...
For this assignment, you will create a BPMN diagram to depict the business process to get...
For this assignment, you will create a BPMN diagram to depict the business process to get a home mortgage based on the following narrative. You can use either DrawIO or BizAgi to create the process drawing. For this process, you can assume that the loan is a refinance not a home purchase. There are some small differences in the process to refinance an existing mortgage than to get a new mortgage. In the following narrative, I'm explaining all of the...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
Background: As a salesperson for Candoo Computer Corporation (CCC), you have just received a call from...
Background: As a salesperson for Candoo Computer Corporation (CCC), you have just received a call from your regional manager regarding a program now underway at one of your key accounts, Farmland Companies. Farmland is a national insurance company with agency offices spread across the United States. The company is in the early stages of designing and specifying a computer system that will place a computer in each agency office. The system will allow each agency to develop, operate, and maintain...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT