|
1 |
| -#include <pthread.h> |
2 |
| -#include <stdlib.h> |
3 |
| -#include <assert.h> |
4 |
| - |
5 |
| -pthread_mutex_t lock_never_unlock_002_glb_mutex = PTHREAD_MUTEX_INITIALIZER; |
6 |
| - |
7 |
| -void* lock_never_unlock_002_tsk_001(void* pram) { |
8 |
| - pthread_mutex_lock(&lock_never_unlock_002_glb_mutex); |
9 |
| - pthread_mutex_unlock(&lock_never_unlock_002_glb_mutex); |
10 |
| - return NULL; |
11 |
| -} |
12 |
| - |
13 |
| -void main() { |
14 |
| - pthread_t tid1; |
15 |
| - pthread_t tid2; |
16 |
| - pthread_mutex_init(&lock_never_unlock_002_glb_mutex, NULL); |
17 |
| - pthread_create(&tid1, NULL, lock_never_unlock_002_tsk_001, NULL); |
18 |
| - pthread_create(&tid2, NULL, lock_never_unlock_002_tsk_001, NULL); |
19 |
| - pthread_join(tid1, NULL); |
20 |
| - pthread_join(tid2, NULL); |
21 |
| - // no deadlock in the threads; assertion should be reached |
22 |
| - assert(0); |
23 |
| -} |
| 1 | +#include <pthread.h> |
| 2 | +#include <stdlib.h> |
| 3 | +#include <assert.h> |
| 4 | + |
| 5 | +pthread_mutex_t lock_never_unlock_002_glb_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 6 | + |
| 7 | +void* lock_never_unlock_002_tsk_001(void* pram) { |
| 8 | + pthread_mutex_lock(&lock_never_unlock_002_glb_mutex); |
| 9 | + pthread_mutex_unlock(&lock_never_unlock_002_glb_mutex); |
| 10 | + return NULL; |
| 11 | +} |
| 12 | + |
| 13 | +void main() { |
| 14 | + pthread_t tid1; |
| 15 | + pthread_t tid2; |
| 16 | + pthread_mutex_init(&lock_never_unlock_002_glb_mutex, NULL); |
| 17 | + pthread_create(&tid1, NULL, lock_never_unlock_002_tsk_001, NULL); |
| 18 | + pthread_create(&tid2, NULL, lock_never_unlock_002_tsk_001, NULL); |
| 19 | + pthread_join(tid1, NULL); |
| 20 | + pthread_join(tid2, NULL); |
| 21 | + // no deadlock in the threads; assertion should be reached |
| 22 | + assert(0); |
| 23 | +} |
0 commit comments