Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2697
Modified Files:
Tag: devel_0_38
m_sched.c
Log Message:
tweaking scheduler
Index: m_sched.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v
retrieving revision 1.5.4.29
retrieving revision 1.5.4.30
diff -C2 -d -r1.5.4.29 -r1.5.4.30
*** m_sched.c 13 May 2005 15:00:19 -0000 1.5.4.29
--- m_sched.c 13 May 2005 15:31:22 -0000 1.5.4.30
***************
*** 218,222 ****
"DAC blocked",
"A/D/A sync",
! "data late"
};
--- 218,224 ----
"DAC blocked",
"A/D/A sync",
! "data late",
! "xrun",
! "sys_lock timeout"
};
***************
*** 377,380 ****
--- 379,383 ----
run_clock_callbacks(next_sys_time); /* tb: is the dsp tick the right place for this? */
sys_time = next_sys_time;
+ sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */
dsp_tick();
}
***************
*** 408,412 ****
/* T.Grill - lock mutex */
sys_lock();
!
sys_clearhist();
--- 411,415 ----
/* T.Grill - lock mutex */
sys_lock();
!
sys_clearhist();
***************
*** 421,425 ****
callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */
!
while (!sys_quit)
{
--- 424,428 ----
callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */
!
while (!sys_quit)
{
***************
*** 486,490 ****
--- 489,495 ----
if (timeforward != SENDDACS_SLEPT)
{
+ sys_unlock();
run_idle_callbacks(sys_sleepgrain);
+ sys_lock();
}
}
***************
*** 494,501 ****
{
int didsomething = 0;
!
sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
sys_pollmidiqueue();
if (sys_pollgui())
--- 499,509 ----
{
int didsomething = 0;
!
sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
+
sys_pollmidiqueue();
+ sys_unlock();
+ sys_lock();
if (sys_pollgui())
***************
*** 506,516 ****
--- 514,529 ----
didsomething = 1;
}
+
/* test for idle; if so, do graphics updates. */
if (!didsomething)
{
sched_pollformeters();
+ sys_unlock();
+ sys_lock();
}
+ sys_unlock();
run_idle_callbacks(sys_sleepgrain);
+ sys_lock();
}
sys_keepsched = 1;
***************
*** 530,539 ****
void sys_lock(void)
{
! pthread_mutex_lock(&sys_mutex);
}
void sys_unlock(void)
{
! pthread_mutex_unlock(&sys_mutex);
}
--- 543,552 ----
void sys_lock(void)
{
! pthread_mutex_lock(&sys_mutex);
}
void sys_unlock(void)
{
! pthread_mutex_unlock(&sys_mutex);
}
***************
*** 547,570 ****
int sys_timedlock(int microsec)
{
! #if 0 /* this would be the clean solution, why doesn't it work??? */
struct timespec timeout;
timeout.tv_sec = 0;
! timeout.tv_nsec = 1000 * microsec;
!
! return pthread_mutex_timedlock(&sys_mutex, &timeout);
#else
! 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;
#endif
}
--- 560,575 ----
int sys_timedlock(int microsec)
{
! #if 0 /* pthread_mutex_timedlock is broken :-( */
struct timespec timeout;
+ int ret;
timeout.tv_sec = 0;
! timeout.tv_nsec = microsec * 1000;
!
! ret = pthread_mutex_timedlock(&sys_mutex, &timeout);
!
! return ret;
#else
! /* todo: find a clean solution */
! sys_lock();
#endif
}
***************
*** 629,633 ****
static t_sched_callback *ringbuffer_head;
-
static void run_idle_callbacks(int microsec)
{
--- 634,637 ----
***************
*** 635,640 ****
double stop;
- sys_unlock();
-
stop = sys_getrealtime()*1.e6 + (double)microsec;
--- 639,642 ----
***************
*** 706,710 ****
else
sys_microsleep(microsec);
- sys_lock();
}
/* } tb */
--- 708,712 ----
else
sys_microsleep(microsec);
}
/* } tb */
+