0% found this document useful (0 votes)
108 views3 pages

OS Assignment

This document contains answers to three questions about running C programs in Linux using the gcc compiler and fork() and exec() system calls. The first question is answered by explaining how to create, compile, and run a simple "Hello World" C program. The second question is answered by explaining that the fork() system call creates a new child process that runs concurrently with the parent process. The third question is answered by explaining that the exec() system call replaces the current program with a new program in the same process.

Uploaded by

umer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views3 pages

OS Assignment

This document contains answers to three questions about running C programs in Linux using the gcc compiler and fork() and exec() system calls. The first question is answered by explaining how to create, compile, and run a simple "Hello World" C program. The second question is answered by explaining that the fork() system call creates a new child process that runs concurrently with the parent process. The third question is answered by explaining that the exec() system call replaces the current program with a new program in the same process.

Uploaded by

umer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Umer Waseem

Section B
Bcs02153308

Q1:Write a simple “Hello World” program in C and compile it under Linux


(any flavor) using gcc compiler.
Ans: gedit use for create file any type of extension I have create code1.c
file create and then write the code in that particular file. gcc is Compiler for
Linux. –o is mode of gcc compiler. In that Problem only print Hello World.
That program in c basic.

Q2: Run and see the output of the fork() program (Nag.c) discussed in the
class.
Ans: gedit use for create file any type of extension I have create code2.c
file create and then write the code in that particular file. gcc is Compiler for
Linux. –o is mode of gcc compiler.
In That Program Fork system call use for creates a new process, which is
called child process, which runs concurrently with process (which process
called system call fork) and this process is called parent process. After a
new child process created, both processes will execute the next instruction
following the fork() system call. A child process use same pc(program
counter), same CPU registers, same open files which use in parent
process.

Q3: Run and see the output of the exec() program (HungryEyes.c)
discussed in the class.
Ans: exec is used when the user wants to launch a new file or program in
the same process. The exec system call is used to execute a file which is
residing in an active process. When exec is called the previous executable
file is replaced and new file is executed.
More precisely, we can say that using exec system call will replace the old
file or program from the process with a new file or program. The entire
content of the process is replaced with a new program.
In That Program Use xeyes File for Eyes View Show.

You might also like