Revision 10 logic/trunk/src/startup/main.c

View differences:

main.c
1
/*
2
 * main.c
3
 *
4
 * 2011, Aleksander Besir (alex.besir@gmail.com)
5
 *
6
 */
7
 
8
#include "../hci_comm/hci_comm.h"
9
#include <stdio.h>
10
#include <pthread.h>
11

  
12
// Inter-thread shared variables
13
// TODO: These variables could be configuration variables
14
//       (eg: static boolean loggingEnabled)
15

  
16
// Crtitical section mutual exclusion security
17
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
18

  
19
// Application entry point
20
int main(int argc, char *argv[]) {
21

  
22
	pthread_t hciConnectionThread;
23
	pthread_t decisionMakingThread;
24
	
25
	pthread_create(&hciConnectionThread,NULL,hciConnectionThread_routine,NULL);
26
	pthread_create(&decisionMakingThread,NULL,decisionMakingThread_routine,NULL);
27
	
28
	pthread_join(hciConnectionThread,NULL);
29
	pthread_join(decisionMakingThread,NULL);
30
	
31
	exit(0);
32

  
33
}
34

  
35
// Decision-making thread routine
36
// Should just call a function that implements decision making module of the logic
37
void *decisionMakingThread_routine(void *dummy) {
38
	
39
	// TODO: Implemet decision making
40
	
41
	pthread_exit(0);
42
	
43
}
44

  
45
// HCI connection thread routine
46
// Start listening to some port
47
void *hciConnectionThread_routine(void *dummy) {
48

  
49
	int hciErrorCode = listenTo(1100);
50
	
51
	pthread_exit(0);
52

  
53
}
1
/*
2
 * main.c
3
 *
4
 * 2011, Aleksander Besir (alex.besir@gmail.com)
5
 *
6
 */
7

  
8
#include "../hci_comm/hci_comm.h"
9
#include <stdio.h>
10
#include <pthread.h>
11

  
12
// Inter-thread shared variables
13
// TODO: These variables could be configuration variables
14
//       (eg: static boolean loggingEnabled)
15

  
16
// Crtitical section mutual exclusion security
17
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
18

  
19
void *decisionMakingThread_routine(void *dummy);
20
void *hciConnectionThread_routine(void *dummy);
21

  
22
// Application entry point
23
int main(int argc, char *argv[]) {
24

  
25
    printf("Hello world!\n");
26

  
27
    setDeviceList();
28

  
29
	pthread_t hciConnectionThread;
30
	pthread_t decisionMakingThread;
31

  
32
	pthread_create(&hciConnectionThread,NULL,hciConnectionThread_routine,NULL);
33
	pthread_create(&decisionMakingThread,NULL,decisionMakingThread_routine,NULL);
34

  
35
	pthread_join(hciConnectionThread,NULL);
36
	pthread_join(decisionMakingThread,NULL);
37

  
38
	exit(0);
39

  
40
}
41

  
42
// Decision-making thread routine
43
// Should just call a function that implements decision making module of the logic
44
void *decisionMakingThread_routine(void *dummy) {
45

  
46
	// TODO: Implemet decision making
47

  
48
	pthread_exit(0);
49

  
50
}
51

  
52
// HCI connection thread routine
53
// Start listening to some port
54
void *hciConnectionThread_routine(void *dummy) {
55

  
56
	int hciErrorCode = listenTo(1100);
57

  
58
	pthread_exit(0);
59

  
60
}

Also available in: Unified diff