Revision e360ce71
inc/urt_core.h | ||
---|---|---|
58 | 58 |
urt_osMutex_t* urtCoreGetMutex(void); |
59 | 59 |
urt_osEventSource_t* urtCoreGetEvtSource(void); |
60 | 60 |
urt_node_t* urtCoreGetNodes(void); |
61 |
void urtCoreSetNodes(urt_node_t* node); |
|
61 | 62 |
void urtCoreStartNodes(void); |
62 | 63 |
urt_status_t urtCoreSynchronizeNodes(urt_node_t* node); |
63 | 64 |
urt_status_t urtCoreStopNodes(urt_status_t reason); |
src/urt_core.c | ||
---|---|---|
117 | 117 |
return &core._evtSource; |
118 | 118 |
} |
119 | 119 |
|
120 |
|
|
121 |
/** |
|
122 |
* @brief Get Core nodes. |
|
123 |
* |
|
124 |
* @return Nodes registered to the core. |
|
125 |
*/ |
|
120 | 126 |
urt_node_t* urtCoreGetNodes(void) |
121 | 127 |
{ |
122 | 128 |
return core._nodes; |
123 | 129 |
} |
124 | 130 |
|
131 |
void urtCoreSetNodes(urt_node_t* node) |
|
132 |
{ |
|
133 |
core._nodes = node; |
|
134 |
return; |
|
135 |
} |
|
136 |
|
|
125 | 137 |
/** |
126 | 138 |
* @brief Start threads of all nodes of the Core. |
127 | 139 |
*/ |
... | ... | |
133 | 145 |
{ |
134 | 146 |
urtThreadStart(node->thread); |
135 | 147 |
node = node->next; |
148 |
urtThreadMSleep(100); //TODO: delete |
|
136 | 149 |
} |
137 | 150 |
urtMutexUnlock(&core._lock); |
138 | 151 |
return; |
... | ... | |
153 | 166 |
urtDebugAssert(node != NULL); |
154 | 167 |
|
155 | 168 |
urtMutexLock(&core._lock); |
156 |
node->stage -= 1;
|
|
169 |
node->stage++;
|
|
157 | 170 |
urt_node_t* nodeFromCore = core._nodes; |
158 | 171 |
while (nodeFromCore && nodeFromCore->stage == node->stage) |
159 | 172 |
{ |
160 | 173 |
nodeFromCore = nodeFromCore->next; |
161 | 174 |
} |
162 |
if (nodeFromCore) |
|
175 |
|
|
176 |
if (!nodeFromCore) |
|
163 | 177 |
{ |
164 | 178 |
urt_osEventFlags_t flag = URT_EVENTFLAG_PROCEED; |
165 | 179 |
urtEventSourceBroadcast(&core._evtSource, flag); |
src/urt_node.c | ||
---|---|---|
69 | 69 |
urtCoreSynchronizeNodes(((urt_node_t*)arg)); |
70 | 70 |
} |
71 | 71 |
|
72 |
while (!urtThreadShouldTerminate()) |
|
72 |
|
|
73 |
while (/*!*/urtThreadShouldTerminate()) //TODO: uncomment |
|
73 | 74 |
{ |
74 | 75 |
urt_osEventMask_t temp = urtEventWait(mask, URT_EVENT_WAIT_ONE, URT_DELAY_INFINITE); |
75 | 76 |
if (temp == urtCoreGetEventMask()) |
... | ... | |
90 | 91 |
((urt_node_t*)arg)->shutdowncallback(((urt_node_t*)arg), urtCoreGetStatus(), ((urt_node_t*)arg)->shutdownparams); |
91 | 92 |
} |
92 | 93 |
urtEventUnregister(urtCoreGetEvtSource(), &((urt_node_t*)arg)->listener); |
93 |
|
|
94 | 94 |
urt_osThread_t* threadToTerminate = ((urt_node_t*)arg)->thread; |
95 | 95 |
while (threadToTerminate->children != NULL || threadToTerminate->sibling != NULL) |
96 | 96 |
{ |
... | ... | |
109 | 109 |
if(threadToJoin->sibling != NULL) |
110 | 110 |
urtThreadJoin(threadToJoin->sibling); |
111 | 111 |
} |
112 |
urtThreadJoin(threadToJoin);
|
|
112 |
//urtThreadJoin(threadToJoin); //TODO: uncomment
|
|
113 | 113 |
|
114 | 114 |
return; |
115 | 115 |
} |
... | ... | |
146 | 146 |
urtDebugAssert(setupparams == NULL); |
147 | 147 |
|
148 | 148 |
node->next = NULL; |
149 |
urtPrintf("Test before threadInit in node\n"); |
|
150 |
urtThreadMSleep(10); |
|
151 | 149 |
node->thread = urtThreadInit((void*)thread, sizeof(thread), prio, (urt_osThreadFunction_t) _main, (void*)node); |
152 |
urtPrintf("Test after threadInit in node\n"); |
|
153 |
urtThreadMSleep(10); |
|
154 | 150 |
node->setupcallback = setupcallback; |
155 | 151 |
node->setupparams = setupparams; |
156 | 152 |
node->loopcallback = loopcallback; |
... | ... | |
165 | 161 |
urt_osMutex_t* mutexTemp = urtCoreGetMutex(); |
166 | 162 |
urtMutexLock(mutexTemp); |
167 | 163 |
node->next = urtCoreGetNodes(); |
168 |
urt_node_t* nodeCore = urtCoreGetNodes(); |
|
169 |
nodeCore->next = node; |
|
164 |
urtCoreSetNodes(node); |
|
170 | 165 |
urtMutexUnlock(mutexTemp); |
171 | 166 |
return; |
172 | 167 |
} |
Also available in: Unified diff