Esempio n. 1
0
File: test11.c Progetto: rosly/rados
int task2_proc(void *OS_UNUSED(param))
{
   while ((cnt2) < TEST_CYCLES) {
      (cnt2)++;
      os_yield();
   }

   return 0;
}
Esempio n. 2
0
File: test11.c Progetto: rosly/rados
int task1_proc(void *OS_UNUSED(param))
{
   while ((cnt1) < TEST_CYCLES) {
      (cnt1)++;
      os_yield();
      test_assert(cnt1 == cnt2);
   }

   return 0;
}
Esempio n. 3
0
/* this task will progres only if task2 will keep up */
int task1_proc(void* OS_UNUSED(param))
{
   while ((cnt1) < TEST_CYCLES)
   {
      if (cnt1 != cnt2)
      {
         /* here we will switch to task2 (equal prio) but since task2 does not
          * call os_yield() than return will be possible only if os_tick() will
          * kick in */
         os_yield();
      }
      (cnt1)++;
   }

   return 0;
}
Esempio n. 4
0
SWITCH_DECLARE(void) switch_cond_next(void)
{
	if (globals.timer_count >= runtime.tipping_point) {
		os_yield();
		return;
	}
#ifdef DISABLE_1MS_COND
	do_sleep(1000);
#else
	if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) {
		do_sleep(1000);
		return;
	}
	switch_mutex_lock(TIMER_MATRIX[1].mutex);
	switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
	switch_mutex_unlock(TIMER_MATRIX[1].mutex);
#endif
}
Esempio n. 5
0
static switch_status_t timer_next(switch_timer_t *timer)
{
	timer_private_t *private_info = timer->private_info;

#ifdef DISABLE_1MS_COND
	int cond_index = timer->interval;
#else
	int cond_index = 1;
#endif
	int delta = (int) (private_info->reference - TIMER_MATRIX[timer->interval].tick);

	/* sync up timer if it's not been called for a while otherwise it will return instantly several times until it catches up */
	if (delta < -1) {
		private_info->reference = timer->tick = TIMER_MATRIX[timer->interval].tick;
	}
	timer_step(timer);

	if (!MATRIX) {
		do_sleep(1000 * timer->interval);
		goto end;
	}

	while (globals.RUNNING == 1 && private_info->ready && TIMER_MATRIX[timer->interval].tick < private_info->reference) {
		check_roll();

		if (globals.timer_count >= runtime.tipping_point) {
			os_yield();
			globals.use_cond_yield = 0;
		} else {
			if (globals.use_cond_yield == 1) {
				switch_mutex_lock(TIMER_MATRIX[cond_index].mutex);
				if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
					switch_thread_cond_wait(TIMER_MATRIX[cond_index].cond, TIMER_MATRIX[cond_index].mutex);
				}
				switch_mutex_unlock(TIMER_MATRIX[cond_index].mutex);
			} else {
				do_sleep(1000);
			}
		}
	}

  end:
	return globals.RUNNING == 1 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}