801
|
1 #ifndef INCLUDED_CPU_THREADS
|
|
2 #define INCLUDED_CPU_THREADS
|
|
3
|
|
4 #include <pthread.h>
|
817
|
5 #include "Threads.h"
|
801
|
6 #include "TaskManagerImpl.h"
|
|
7 #include "MainScheduler.h"
|
|
8
|
|
9 typedef struct cpu_arg {
|
|
10 int cpuid;
|
|
11 // should be syncrhonized
|
|
12 MainScheduler *scheduler;
|
|
13 TaskManagerImpl *manager;
|
|
14 } cpu_thread_arg_t;
|
|
15
|
817
|
16 class CpuThreads : Threads {
|
801
|
17 public:
|
|
18 /* constructor */
|
|
19 CpuThreads(int num = 1, int start_id = 0);
|
|
20 virtual ~CpuThreads();
|
|
21 static void *cpu_thread_run(void *args);
|
|
22
|
|
23 /* functions */
|
|
24 void init();
|
|
25 int get_mail(int speid, int count, memaddr *ret); // BLOCKING
|
|
26 int has_mail(int speid, int count, memaddr *ret); // NONBLOCK
|
|
27 void send_mail(int speid, int num, memaddr *data); // BLOCKING
|
|
28
|
|
29 private:
|
|
30 /* variables */
|
|
31 pthread_t *threads;
|
|
32 cpu_thread_arg_t *args;
|
|
33 int cpu_num;
|
|
34 int id_offset;
|
|
35 };
|
|
36
|
|
37 #endif
|