SV: [En-Nut-Discussion] cgi functions

Ole Reinhardt ole.reinhardt at kernelconcepts.de
Tue May 24 11:30:00 CEST 2005


Hi!


> cgifunc(FILE *stream, REQUEST *req)
> {
> 	...
> 	MsgQPost(...);
> 	...
> 	SemWait(...);
> 	...
> }
> THREAD(thread_a, arg)
> {
> 	...
> 	MsgQGet(...);
> 	...
> 	SemPost(...);
> 	...
> }

First question: Why don't you process everything directly in the
cgifunc? The function will block anyway. And at this point you should
better use NutEventPost as your code will reach a much better
performance. To share data between these two threads simply use global
structs. On an embedded system like the ethernut board you can safly
forget most of what you learnd about multi threaded programming ;-)
Since we use cooperative multitasking you won't run into critical
sections that easy. At every line of your code you will know if there is
a context switch or not.


> But I got some strange behaviours, like the system restarts or hangs. How do
> I know if I have run out of memory? Is there any more things to consider? 

For me that sounds like you pass a handle instead of a pointer to this
handly to a function.

HANDLE event = NULL;

NutEventPost(event); will write into a random location and will perhaps
hang the cpu.

NutEventPost(&event); will do what you expected.

Regards,

Ole

-- 
kernel concepts    Tel: +49-271-771091-14
Dreisbachstr. 24   Fax: +49-271-771091-19
D-57250 Netphen    E+ : +49-177-7420433
--





More information about the En-Nut-Discussion mailing list