Skip to content

ozanmujde/Dining-philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Dining philosophers

Usage

To compile

$ gcc -Wall -o "hw2" "hw2.c" -lpthread 

And to run the file

$ ./hw2 5
$ ./hw2 <Grup number>

Description

Our code run multiple times for each group you can enter group number as args. If group number < 2 and > 1000 it'll automatically assigned to 5

Each philosopher has to eat pilaf. Until this happen pilaf will refill and money will be charged. If you want to test is pilaf refilled or not you can set gram to 500. Person and gram of pilaf can be changed.

Each philosopher have thread priority between 0 and 5

pthread_attr_getschedparam (&attr, &param);
	param.sched_priority = (rand() % 5 ); 
	printf("Thread %d has priority %d\n",i,param.sched_priority);
	pthread_attr_setschedparam (&attr, &param);
				
	pthread_create(&thread_id[i], &attr,
		philospher, &phil[i]);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages