-
Notifications
You must be signed in to change notification settings - Fork 0
/
threads.h
50 lines (39 loc) · 1.06 KB
/
threads.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//======================================================
// threads.h
//
// COMP 3430 - Operating Systems - Assignment 2 Frogger
//
// Header file for threads.c
//
// @author Andy Lun
// @date June 09, 2017
//======================================================
#ifndef THREADS_H
#define THREADS_H
#include <pthread.h>
#include <stdbool.h>
#define THREAD_REFRESH_SCREEN 0
#define THREAD_FROG 1
#define THREAD_FROG_ANIMATION 2
#define THREAD_UPKEEP 3
#define NUM_THREADS 8
bool end_of_game;
pthread_cond_t condition_quit;
pthread_mutex_t mutex_condition;
pthread_mutex_t mutex_console;
pthread_mutex_t mutex_frog;
pthread_mutex_t mutex_logs;
pthread_t threads[NUM_THREADS];
void init_condition();
void wait_condition();
void trigger_condition();
void destroy_condition();
void init_mutex();
void lock_mutex(pthread_mutex_t* mutex);
void unlock_mutex(pthread_mutex_t* mutex);
void destroy_mutex();
pthread_t init_thread(char* name, void* func, void* args);
void* exit_thread();
void join_thread(pthread_t thread);
void sleep_thread(int sleep_ticks);
#endif // THREADS_H