Skip to content

In this project, you will learn the basics of threading a process. You will see how to create threads and you will discover mutexes.

License

Notifications You must be signed in to change notification settings

aabduvak/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 

🍝 Philosophers

I’ve never thought philosophy would be so deadly


Github top language Github language count Repository size GitHub last commit

About   |   Links   |   Functions   |   Starting   |   Author


About

Philosophers (represented by parts of a program) sit around a table, with a big plate of spaghetti at its center. They each have a fork, but they need two forks to eat ; so they need to borrow their neighbor's fork to eat.

Of course, if they borrow a neighbor's fork, the neighbor can't use the fork. The processes / threads must communicate, to know the state of the forks (and of the other philosophers) at all times. There must also be a parent process that monitors everything.

Objectives

  • Unix logic

Skills

  • Rigor
  • Unix
  • Algorithms & AI

My grade

Functions

Only the following functions are allowed to be used in this project on mandatory part:

Function Description Function Description
memset fill memory with a constant byte pthread_create create a new thread
printf format and print data pthread_detach detach a thread
malloc allocate dynamic memory pthread_join join with a terminated thread
free free dynamic memory pthread_mutex_init initialise the mutex
write write to a file descriptor pthread_mutex_destroy destroy the mutex object
usleep suspend execution for microsecond intervals pthread_mutex_lock lock the mutex object
gettimeofday get the time and gives the number of seconds and microseconds since the Epoch pthread_mutex_unlock releases the mutex object

Starting

# Clone this project
git clone https://github.com/aabduvak/philosophers
# Access
cd philosophers/philo/
# Compile the program
make
# To run (example)
./philo 10 80 80 80 2
# To remove objects
make clean
# To remove objects and executable
make fclean

Links

About

In this project, you will learn the basics of threading a process. You will see how to create threads and you will discover mutexes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published