2294c73e6a3384929c8df97b52b4d9d59837c840
options :
- n_phi -> number_of_philosophers
- t_die -> time_to_die
- t_eat -> time_to_eat
- t_slp -> time_to_sleep
- n_est -> [number_of_times_each_philosopher_must_eat]
thread :
- thread are light-weight-process (LWP) that happens inside a process
- a process can be single-threaded or multi-threaded
- different process have a unique PID with a unique LWP, different thread in the same process have the same PID and a different LWP
- thread vs process :
process :
- process is isolated, it doesn't share memory with any other process
- process can have states : new, ready, running, waiting, terminated, suspended
- process is less efficient in communication, it takes more times to create or terminate or switch
- process speed is not impacted by speed of other process (untill it reach the limit of cpu)
- process are created with fork() and execve() (to duplicate a process in a child process, or replacing an existing process) thread :
- thread are not isolated
- thread can have states : running, ready, blocked
- thread is more efficient in communication, it takes less times to create or terminate or switch
- thread can become slow if the process does many concurrent tasks
- ressources :
external function :
memset: fill memory with a constant byteprintf: format and print datamalloc: allocate dynamic memoryfree: free dynamic memorywrite: write to a file descriptorusleep: suspend execution for microseconds intervalsgettimeofday: get timepthread_create: create a new threadpthread_detach:pthread_joinpthread_mutex_initpthread_mutex_destroypthread_mutex_lockpthread_mutex_unlock
Description
Languages
C
96.2%
Makefile
3.8%