Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Operating System Practical (CS604p) Total marks = 20

Assignment # 01 Deadline
23/11/2023
Fall 2023

Please carefully read the following instructions before attempting the assignment.

RULES FOR MARKING


It should be clear that your assignment would not get any credit if:
 The assignment is submitted after the due date.
 Strict action will be taken if the submitted solution is copied from any other student or the internet.

You should consult the recommended books to clarify your concepts as handouts are not sufficient.

UPLOADING INLINE ASSIGNMENT INSTRUCTION


Follow the given instructions to submit Inline assignments:
Microsoft Word (doc/docx) and Adobe Acrobat (pdf) file uploading options will not be available in inline
assignment submission.
 Students can submit HTML, Images, and plain text only in this inline Mode. You may also insert an image
file/table.
 Students can insert the images or snapshots in the following formats.

 Images and tables can be inserted using the following highlighted option in the interface .

OBJECTIVE
 The objective of this assignment is to provide hands-on experience in the:
 Linux Thread
 Thread creation APIs
 Compiling and Running C Programs in a Linux environment.
NOTE

No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding
or internet malfunctioning etc.). Hence refrain from uploading assignments in the last hour of the deadline. It is
recommended to upload the solution at least two days before its closing date.

If you people find any mistake or confusion in the assignment (Question statement), please consult with your
instructor before the deadline. After the deadline, no queries will be entertained in this regard.

For any query, feel free to email me at:


cs604p@vu.edu.pk
Questions No 01 20 marks

You are required to create the C program, that creates the two user-level threads named T1 and T2 by using
the pthread_create() API function, the functionality of the two threads are as follows.
 The first thread T1, should print the table 5, and from the main program you should pass the
parameter value of 5 as an integer to the T1 thread to print the required table of 5.
 In the second thread T2, it should print your name on the screen. Secondly, your name should be
passed to the T2 from the main() function as a character array.
In the main function call the pthread_join() function to wait for the main function for both threads.

The following should be the flow of your program.


 Firstly, compile your C program through the command line.
 Link the pthread library with your program (by using the –lpthread option in the compiler command)
 Pass the _REENTRANT macro from the command line
 Run your program.
Note: You are required to send the screenshot along with the C Code.
Following is the sample screenshot:

Note: in case you have installed the Virtual Box you can take the screenshot as follows. Go to the view
menu and click on Take Screenshot as follows.
See the following link for the installation of Virtual Box and Ubuntu (Linux) on your system.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?
File=tutorial_for_installing_virtualbox_and_ubuntu.mp4

See the following link installing gcc and compiling and running your first program in Linux.
https://vulms.vu.edu.pk/CourseResources/OpenFile.aspx?File=How%20to%20install%20gcc%20on
%20Ubuntu%20and%20compile%20a%20C%20program.mp4

The End

You might also like