1. Download the sources of the Linux kernel (of the version matching the kernel version of your current installation) from into some directory in your home directory. Unzip and untar it. Change into the root directory of the kernel source tree. Traverse through the directories. Find out where the getpid system call is located in the kernel sources. Write down the name of that file. Describe how you found that file. Examine that source file. What is the name of the corresponding system call routine? Write down the implementation of the getpid system all. What is the number of the getpid system call. Describe how you found that number.

2. Learn the architectures that Linux supports from the arch subdirectory of the Linux kernel source tree. Write them down.

3. Write a small C program in the Linux environment. The program will just compute the average of the integers that are found in a given input file. The first line in the file should contain the number of integers, and the remaining lines should contain the actual integers, one integer per line. The output will be written to the screen. Compile the program with gcc. Use the -g and -w options for the compiler. Run the program. Provide the listing of the source code of the program.

4. Exercise with the strace utility. Print out a sample output using one of the basic Linux commands such as ls, cp, ps. Also write down the strace output for the executable that you built in the previous step.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]){
    FILE * fp;
    int nLines, line, number, sum= 0;
    double mean;

    if (argc!= 2){
            fprintf(stderr, "error: filename\n");
            return 1;

    fp = fopen(argv[1], "r");
    if (fp == NULL){
            fprintf(stderr,"error: file\n");
            return 2;

    fscanf(fp, "%d", &nLines);

    for(line= 1; line<= nLines; line++){
       fscanf(fp, "%d", &number);
       sum+= number;

    mean = sum/ nLines;
    printf("%.2f\n", mean);

    return 0;
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Linux Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats