Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14267
Modified Files: Tag: devel_0_38 m_sched.c Log Message: sys_lock during dsp cleanup of scheduler (it's probably better to use a real profiler) sys_timedlock()
Index: m_sched.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v retrieving revision 1.5.4.22 retrieving revision 1.5.4.23 diff -C2 -d -r1.5.4.22 -r1.5.4.23 *** m_sched.c 9 Apr 2005 06:51:13 -0000 1.5.4.22 --- m_sched.c 17 Apr 2005 10:11:32 -0000 1.5.4.23 *************** *** 435,450 **** if (sched_usedacs) { - #ifdef THREAD_LOCKING - /* T.Grill - send_dacs may sleep -> - unlock thread lock make that time available - - could messaging do any harm while sys_send_dacs is running? - */ - sys_unlock(); - #endif timeforward = sys_send_dacs(); - #ifdef THREAD_LOCKING - /* T.Grill - done */ - sys_unlock(); - #endif /* if dacs remain "idle" for 1 sec, they're hung up. */ if (timeforward != 0) --- 435,439 ---- *************** *** 488,493 **** if (sys_pollgui()) { ! if (!didsomething) ! sched_didpoll++; didsomething = 1; } --- 477,482 ---- if (sys_pollgui()) { ! /* if (!didsomething) */ ! /* sched_didpoll++; */ didsomething = 1; } *************** *** 501,515 **** /* sys_reportidle(); */
#ifdef THREAD_LOCKING /* T.Grill - enter idle phase -> unlock thread lock */ ! sys_unlock(); #endif ! /* tb: call idle callbacks */ ! run_idle_callbacks(timeforward != SENDDACS_SLEPT?sys_sleepgrain:0); ! #ifdef THREAD_LOCKING /* T.Grill - leave idle phase -> lock thread lock */ ! sys_lock(); #endif /* sys_addhist(5); */ /* sched_didnothing++; */ --- 490,507 ---- /* sys_reportidle(); */
+ /* tb: call idle callbacks */ + if (timeforward != SENDDACS_SLEPT) + { #ifdef THREAD_LOCKING /* T.Grill - enter idle phase -> unlock thread lock */ ! sys_unlock(); #endif ! run_idle_callbacks(sys_sleepgrain); #ifdef THREAD_LOCKING /* T.Grill - leave idle phase -> lock thread lock */ ! sys_lock(); #endif + } + /* sys_addhist(5); */ /* sched_didnothing++; */ *************** *** 525,534 ****
sys_pollmidiqueue(); if (sys_pollgui()) - { - if (!didsomething) - sched_didpoll++; didsomething = 1; - }
/* test for idle; if so, do graphics updates. */ --- 517,523 ----
sys_pollmidiqueue(); + if (sys_pollgui()) didsomething = 1;
/* test for idle; if so, do graphics updates. */ *************** *** 550,553 **** --- 539,543 ---- } + #ifdef THREAD_LOCKING /* T.Grill - done */ *************** *** 581,591 ****
/* tb { */ int sys_timedlock(int microsec) { ! struct timespec timeout; ! timeout.tv_sec = 0; ! timeout.tv_nsec = 1000 * microsec;
! return pthread_mutex_timedlock(&sys_mutex, &timeout); } /* tb } */ --- 571,590 ----
/* tb { */ + #include <errno.h> int sys_timedlock(int microsec) { ! int count = microsec * 0.001; ! int ret;
! while (count--) ! { ! ret = sys_trylock(); ! if (ret == 0) ! return 0; ! ! /* sleep for 100 microsecs */ ! sys_microsleep(100); ! } ! return ETIMEDOUT; } /* tb } */