--- trunk/livstidsfanger.c 2014/11/08 12:40:52 12 +++ trunk/livstidsfanger.c 2014/11/19 19:32:53 15 @@ -1,4 +1,4 @@ -// Programmet bruker ISO C 2011 (ISO/IEC 9899:2011) og Pthreads (IEEE Std 1003.1c-1995). -*- coding: utf-8 -*- +// Programmet bruker ISO C 2011 (ISO/IEC 9899:2011) og Pthreads (IEEE Std 1003.1c-2001). -*- coding: utf-8 -*- // Løsning programmert av Trond Endrestøl , 2014-11-06. // $Ximalas$ @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,10 @@ #include #include +#if _POSIX_THREADS < 200112L +#error her mangler det støtte for POSIX Threads anno 2001 +#endif + #if __STDC_VERSION__ >= 201112L #include #else @@ -177,6 +182,10 @@ noreturn void *livstidsfange(void *arg) printf("livstidsfange %2zu låser opp mutex\n", i + 1); pthread_mutex_unlock(&mutex); printf("livstidsfange %2zu har låst opp mutex\n", i + 1); + +#ifdef _POSIX_PRIORITY_SCHEDULING + sched_yield(); +#endif } // while } // livstidsfange()