Skip to contentSkip to conversation

reduce stack size in accuracy demo

PATCH New Jan Kiszka 1 participant 1 message Mar 17, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 reduce stack size in accuracy demo

Hi Gilles,

running your accuracy demo on a resource restricted system aside a hungry cache benchmark (as load) produced OOM too early. This patch reduces the stack thread sizes (which get locked into memory) - and it also demonstrates how to create RT-pthreads preferably.

Jan

PS: cyclictest now runs as expected with pthread_setschedparam, will post some patch to the list and Thomas. I think it's useful as it can create multiple timed threads, and it's POSIX (latency is native, accuracy tests relative sleeping).

skins/posix/demos/accuracy.c +3 -0
Index: ksrc/skins/posix/demos/accuracy.c
===================================================================
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <semaphore.h>
+#include <limits.h>
 
 #define SEMB_NAME "/semB"
 
@@ -229,6 +230,7 @@ int main (int argc, char **argv)
     pthread_attr_setinheritsched(&thattrA,PTHREAD_EXPLICIT_SCHED);
     pthread_attr_setschedpolicy(&thattrA,SCHED_FIFO);
     pthread_attr_setschedparam(&thattrA,&paramA);
+    pthread_attr_setstacksize(&thattrA,PTHREAD_STACK_MIN);
     err = pthread_create(&thidA,&thattrA,&threadA,NULL);
 
     if (err)
@@ -239,6 +241,7 @@ int main (int argc, char **argv)
     pthread_attr_setinheritsched(&thattrB,PTHREAD_EXPLICIT_SCHED);
     pthread_attr_setschedpolicy(&thattrB,SCHED_FIFO);
     pthread_attr_setschedparam(&thattrB,&paramB);
+    pthread_attr_setstacksize(&thattrB,PTHREAD_STACK_MIN);
     err = pthread_create(&thidB,&thattrB,&threadB,NULL);
 
     if (err)