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

Student ID: Mc160200011

Course: CS 604
Student Name: Muhammad Awais Khalid

Commands used to compile the C program


1:

2:

Following is the code which I use to write the program to display information

#include<stdio.h>

#include<string.h>

#include<pthread.h>

#include<stdlib.h>

#include<unistd.h>

#include <sys/types.h>

pthread_t tid[3];

void* displayInformation(void *arg)

unsigned long i = 0;

pthread_t id = pthread_self();

if(pthread_equal(id,tid[0]))
{

printf("Current Process ID %d and Thread ID %d\n", getpid(), pthread_self());

printf("MC160200011\nMuhammad Awais Khalid\n");

}else if(pthread_equal(id,tid[1]))

printf("\nCurrent Parent ID %d and Parent ID %d.", getppid(), pthread_self());

printf("\nCS604\nOperating System\n");

}else if (pthread_equal(id,tid[2])){

printf("\nCurrent Parent ID %d and Parent ID %d.", getppid(), pthread_self());

printf("\nMIT\nVirtual University of Pakistan\n");

for(i=0; i<(0xFFFFFFFF);i++);

return NULL;

int main(void)

int i = 0;

while(i < 3)

pthread_create(&(tid[i]), NULL, &displayInformation, NULL);

i++;

while(i < 3)

{
pthread_join(tid[i], NULL);

i++;

sleep(5);

return 0;

Out of the above program is as follows

You might also like