mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5: centralize information on simulate() time reached
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
/* count to infinity in n threads.
|
||||
*
|
||||
* https://github.com/cirosantilli/linux-kernel-module-cheat#pthreads
|
||||
*
|
||||
* Useful if you need to keep several threads around
|
||||
* to test something.
|
||||
|
||||
28
userland/posix/pthread_deadlock.c
Normal file
28
userland/posix/pthread_deadlock.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Let's see a trivial deadlock in action to feel the joys of multithreading.
|
||||
*
|
||||
* https://github.com/cirosantilli/linux-kernel-module-cheat#pthreads
|
||||
*
|
||||
* Exit successfully immediately without any arguments:
|
||||
*
|
||||
* ./pthread_deadlock.out
|
||||
*
|
||||
* Hang forever in a deadlock if one argument is given:
|
||||
*
|
||||
* ....
|
||||
* ./pthread_deadlock.out 0
|
||||
* ....
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 700
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
pthread_mutex_t main_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
(void)(argv);
|
||||
pthread_mutex_lock(&main_thread_mutex);
|
||||
if (argc > 1)
|
||||
pthread_mutex_lock(&main_thread_mutex);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user