Revision 792f6c74
inc/urt_core.h | ||
---|---|---|
55 | 55 |
void urtCoreInit(void); |
56 | 56 |
urt_status_t urtCoreGetStatus(void); |
57 | 57 |
urt_osEventMask_t urtCoreGetEventMask(void); |
58 |
urt_osMutex_t urtCoreGetMutex(void); |
|
58 |
urt_osMutex_t* urtCoreGetMutex(void);
|
|
59 | 59 |
urt_osEventSource_t* urtCoreGetEvtSource(void); |
60 | 60 |
urt_node_t* urtCoreGetNodes(void); |
61 | 61 |
void urtCoreStartNodes(void); |
src/urt_core.c | ||
---|---|---|
39 | 39 |
typedef struct urt_core |
40 | 40 |
{ |
41 | 41 |
urt_node_t* _nodes; |
42 |
urt_osEventSource_t* _evtSource;
|
|
42 |
urt_osEventSource_t _evtSource; |
|
43 | 43 |
urt_osMutex_t _lock; |
44 | 44 |
urt_status_t _status; |
45 | 45 |
#if (URT_CFG_PUBSUB_ENABLED) |
... | ... | |
71 | 71 |
{ |
72 | 72 |
core._nodes = NULL; |
73 | 73 |
core._status = URT_STATUS_OK; |
74 |
urtEventSourceInit(core._evtSource); |
|
74 |
urtEventSourceInit(&core._evtSource);
|
|
75 | 75 |
urtMutexInit(&core._lock); |
76 | 76 |
#if (URT_CFG_PUBSUB_ENABLED) |
77 | 77 |
core._topics = NULL; |
... | ... | |
94 | 94 |
|
95 | 95 |
urt_osEventMask_t urtCoreGetEventMask(void) |
96 | 96 |
{ |
97 |
return EVENT_MASK(32);
|
|
97 |
return URT_EVENTMASK_MAXPRIO;
|
|
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
/** |
... | ... | |
102 | 102 |
* |
103 | 103 |
* @return Current system mutex. |
104 | 104 |
*/ |
105 |
urt_osMutex_t urtCoreGetMutex(void) |
|
105 |
urt_osMutex_t* urtCoreGetMutex(void)
|
|
106 | 106 |
{ |
107 |
return core._lock; |
|
107 |
return &core._lock;
|
|
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
/** |
... | ... | |
114 | 114 |
*/ |
115 | 115 |
urt_osEventSource_t* urtCoreGetEvtSource(void) |
116 | 116 |
{ |
117 |
return core._evtSource; |
|
117 |
return &core._evtSource;
|
|
118 | 118 |
} |
119 | 119 |
|
120 | 120 |
urt_node_t* urtCoreGetNodes(void) |
121 | 121 |
{ |
122 |
return core._nodes; |
|
122 |
return &core._nodes;
|
|
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
/** |
... | ... | |
162 | 162 |
if (nodeFromCore) |
163 | 163 |
{ |
164 | 164 |
urt_osEventFlags_t flag = URT_EVENTFLAG_PROCEED; |
165 |
urtEventSourceBroadcast(core._evtSource, flag); |
|
165 |
urtEventSourceBroadcast(&core._evtSource, flag);
|
|
166 | 166 |
urtMutexUnlock(&core._lock); |
167 | 167 |
return URT_STATUS_OK; |
168 | 168 |
} |
... | ... | |
209 | 209 |
node = node->next; |
210 | 210 |
} |
211 | 211 |
urt_osEventFlags_t flag = URT_EVENTFLAG_TERMINATE; |
212 |
urtEventSourceBroadcast(core._evtSource, flag); |
|
212 |
urtEventSourceBroadcast(&core._evtSource, flag);
|
|
213 | 213 |
urtMutexUnlock(&core._lock); |
214 | 214 |
if (priorityBoosted) |
215 | 215 |
core._nodes->thread->prio = oldPrio; |
src/urt_node.c | ||
---|---|---|
37 | 37 |
/* LOCAL VARIABLES */ |
38 | 38 |
/******************************************************************************/ |
39 | 39 |
|
40 |
urt_node_t localNode; //TODO |
|
40 |
urt_node_t localNode; |
|
41 |
static URT_THREAD_MEMORY(_node_thread, AMIROOS_CFG_SHELL_STACKSIZE); |
|
41 | 42 |
|
42 | 43 |
/******************************************************************************/ |
43 | 44 |
/* LOCAL FUNCTIONS */ |
... | ... | |
63 | 64 |
} |
64 | 65 |
else |
65 | 66 |
{ |
66 |
mask = 0xFFFFFFFF;
|
|
67 |
mask = ALL_EVENTS;
|
|
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
if (urtCoreGetStatus() == URT_STATUS_OK) |
... | ... | |
71 | 72 |
urtCoreSynchronizeNodes(&localNode); |
72 | 73 |
} |
73 | 74 |
|
74 |
bool terminated = false; |
|
75 |
if (terminated /*TODO: replace with function*/) |
|
75 |
if (!urtThreadShouldTerminate()) |
|
76 | 76 |
{ |
77 | 77 |
urt_osEventMask_t temp = urtEventWait(mask, URT_EVENT_WAIT_ONE, URT_DELAY_INFINITE); |
78 | 78 |
if (temp == urtCoreGetEventMask()) |
... | ... | |
93 | 93 |
localNode.shutdowncallback(&localNode, urtCoreGetStatus(), arg); |
94 | 94 |
} |
95 | 95 |
urtEventUnregister(urtCoreGetEvtSource(), &localNode.listener); |
96 |
|
|
97 |
|
|
96 | 98 |
urt_osThread_t* threadToTerminate = localNode.thread; |
97 |
urt_osThread_t* threadToTerminateChild; |
|
98 |
while (threadToTerminate != NULL) |
|
99 |
while (threadToTerminate->children != NULL || threadToTerminate->sibling != NULL) |
|
99 | 100 |
{ |
100 |
threadToTerminateChild = threadToTerminate->children; |
|
101 |
urtThreadTerminate(&threadToTerminate, URT_THREAD_TERMINATE_REQUEST); |
|
102 |
threadToTerminate = threadToTerminateChild; |
|
101 |
if (threadToTerminate->children != NULL) |
|
102 |
urtThreadTerminate(threadToTerminate->children, URT_THREAD_TERMINATE_REQUEST); |
|
103 |
if(threadToTerminate->sibling != NULL) |
|
104 |
urtThreadTerminate(threadToTerminate->sibling, URT_THREAD_TERMINATE_REQUEST); |
|
103 | 105 |
} |
104 |
urtThreadExit(); |
|
106 |
urtThreadTerminate(&threadToTerminate, URT_THREAD_TERMINATE_REQUEST); |
|
107 |
|
|
105 | 108 |
return; |
106 | 109 |
} |
107 | 110 |
|
... | ... | |
138 | 141 |
urtDebugAssert(setupparams == NULL); |
139 | 142 |
|
140 | 143 |
node->next = NULL; |
141 |
void *memory = (void*)0x28ff44; |
|
142 |
urt_osThreadFunction_t func; //TODO: Here the hello world func? |
|
143 |
thread = urtThreadInit(memory, SIZEOF_PTR, URT_THREAD_PRIO_NORMAL_MIN, func, NULL); |
|
144 |
node->thread = thread; |
|
144 |
node->thread = urtThreadInit(_node_thread, sizeof(_node_thread), URT_THREAD_PRIO_NORMAL_MIN, _main, setupparams); |
|
145 | 145 |
node->setupcallback = setupcallback; |
146 | 146 |
node->setupparams = setupparams; |
147 | 147 |
node->loopcallback = loopcallback; |
... | ... | |
153 | 153 |
#if (URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING) |
154 | 154 |
node->loops = 0; |
155 | 155 |
#endif /* URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING */ |
156 |
urt_osMutex_t mutexTemp = urtCoreGetMutex(); |
|
157 |
urtMutexLock(&mutexTemp);
|
|
156 |
urt_osMutex_t* mutexTemp = urtCoreGetMutex();
|
|
157 |
urtMutexLock(mutexTemp); |
|
158 | 158 |
node->next = urtCoreGetNodes(); |
159 | 159 |
urt_node_t* nodeCore = urtCoreGetNodes(); |
160 | 160 |
nodeCore = node; |
161 |
urtMutexUnlock(&mutexTemp);
|
|
161 |
urtMutexUnlock(mutexTemp); |
|
162 | 162 |
localNode = *node; |
163 | 163 |
return; |
164 | 164 |
} |
Also available in: Unified diff