void yarn_resume ( yarn_t yarn ) { if (PTABLE(yarn)->isSuspended) { PTABLE(yarn)->isSuspended = 0; master_sched_reschedule(PTABLE(yarn)->suspensionCore, &(PTABLE(yarn)->suspensionJob)); } }
static yarn_t list_insert ( yarn* active_yarn, int nice ) { yarn_t pid = maxpid++; DEBUG("pid(%d)=yarn(%p)\n", pid, active_yarn); assert(maxpid < YARNS_MAX_PROCESSES); PTABLE(pid) = active_yarn; active_yarn->pid = pid; active_yarn->nice = nice; return pid; }
static void yarn_launcher ( yarn_launch_data* ld ) { TTDGET(); yarn* active_yarn = ld->active_yarn; void (*routine)(void*) = ld->routine; void* udata = ld->udata; // basically a bootstrap routine for each yarn which runs the routine then cleans up yfree(ld); routine(udata); DEBUG("yarn %p completed, yarn_context_set\n", active_yarn); TTD.runtime = UNSCHEDULE; PTABLE(active_yarn->pid) = 0; yarn_context_set(&(TTD.sched_context)); }
void yarn_process ( unsigned long otherThreadCount, int primaryScheduler, int secondaryScheduler ) { // look through yarns unsigned long nprocs; int i; #ifdef YARNS_ENABLE_SMP nprocs = numprocs() - otherThreadCount; if (nprocs < 1) nprocs = 1; master_sched_init(nprocs, primaryScheduler, secondaryScheduler); #else master_sched_init(1, primaryScheduler, secondaryScheduler); #endif #if YARNS_SYNERGY == YARNS_SYNERGY_PREEMPTIVE preempt_init(); preempt_handle = yarn_preempt_handle; #endif TTDINIT_MAIN(); wg = wait_graph_new(); // set up all the yarns in the scheduler for (i = 1; i < maxpid; i++) { master_sched_schedule(i, prio_lookup(PTABLE(i)->nice)); } live = 1; DEBUG("starting with context API: %s\n", YARN_CONTEXT_API); #ifdef YARNS_ENABLE_SMP // create the secondary threads for (i = 1; i < nprocs; i++) { #if YARNS_SYNERGY == YARNS_SYNERGY_PREEMPTIVE preempt_disable(); #endif pthread_create(&threads[i], NULL, (void* (*)(void*))yarn_processor, (void*)i); } #endif threads[i] = pthread_self(); coreCount = nprocs; // run the primary thread yarn_processor(0); }
[POLARIZATION_H] = "H", [POLARIZATION_V] = "V", [POLARIZATION_L] = "L", [POLARIZATION_R] = "R", }; static const char *channel_parse_rolloff[] = { [ROLLOFF_20] = "20", [ROLLOFF_25] = "25", [ROLLOFF_35] = "35", [ROLLOFF_AUTO] = "AUTO", }; static const struct dvb_parse_table sys_atsc_table[] = { { DTV_FREQUENCY, NULL, 0 }, { DTV_MODULATION, PTABLE(channel_parse_modulation) }, }; static const struct dvb_parse_table sys_dvbc_table[] = { { DTV_FREQUENCY, NULL, 0 }, { DTV_SYMBOL_RATE, NULL, 0 }, { DTV_INNER_FEC, PTABLE(channel_parse_code_rate) }, { DTV_MODULATION, PTABLE(channel_parse_modulation) }, }; /* Note: On DVB-S, frequency is divided by 1000 */ static const struct dvb_parse_table sys_dvbs_table[] = { { DTV_FREQUENCY, NULL, 0 }, { DTV_POLARIZATION, PTABLE(channel_parse_polarization) }, { DTV_SYMBOL_RATE, NULL, 0 }, { DTV_INNER_FEC, PTABLE(channel_parse_code_rate) },
static void yarn_processor ( unsigned long procID ) { // this is the main routine run by each thread struct sigaction sa; void* stackRoot; volatile int breakProcessor = 0; int rc; unsigned deadSleepTime = YARNS_DEAD_SLEEP_TIME; // init the thread yarn data TTDINIT(); TTDGET(); // make sure it initted properly assert(&TTD); // repeatedly ask the scheduler for the next job scheduler_job activeJob; #ifdef BASE_CONTEXT_NEEDS_STACK stackRoot = allocate_stack(&(TTD.sched_context)); #endif #if YARNS_SYNERGY == YARNS_SYNERGY_PREEMPTIVE sa.sa_sigaction = (void (*)(int, struct __siginfo *, void *))preempt_signal_handler; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGUSR2); sigaction(SIGUSR2, &sa, 0); #endif activeJob.pid = 0; activeJob.runtime = 0; activeJob.data = 0; activeJob.next = 0; activeJob.priority = SCHED_PRIO_NORMAL; while (!breakProcessor) { TTD.shouldSuspend = 0; if (procID == wgProcResponsibility) { wait_graph_lock(wg); wait_graph_time_process(wg); wait_graph_unlock(wg); wgProcResponsibility++; wgProcResponsibility %= coreCount; } master_sched_select(procID, &activeJob); if (activeJob.pid == 0) { usleep(deadSleepTime); deadSleepTime += (deadSleepTime / 2); continue; } DEBUG("job %lu @ proc %d (rt: %lu us)\n", activeJob.pid, (int)procID, activeJob.runtime); if (activeJob.pid >= maxpid) { DEBUG("got pid %lu which is out-of-bound!\n", activeJob.pid); usleep(deadSleepTime); continue; } if (!PTABLE(activeJob.pid)) { DEBUG("got dead pid %lu\n", activeJob.pid); usleep(deadSleepTime); continue; } // set all the stuff up TTD.yarn_current = PTABLE(activeJob.pid); TTD.start_time = yarns_time(); TTD.next = 0; TTD.runtime = activeJob.runtime; // swap contexts DEBUG("yarn_context_swap to yarn: %p\n", TTD.yarn_current); #if YARNS_SYNERGY == YARNS_SYNERGY_PREEMPTIVE preempt(yarns_time() + activeJob.runtime, procID); preempt_enable(); #endif rc = yarn_context_swap(&(TTD.sched_context), &(TTD.yarn_current->context)); #if YARNS_SYNERGY == YARNS_SYNERGY_PREEMPTIVE preempt_disable(); #endif activeJob.next = TTD.next; // check it actually worked if (rc == 0) perror("yarn_context_swap failed"); // set the runtime #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif activeJob.runtime = MIN(TTD.runtime, activeJob.runtime); // if we're unscheduling, yfree up memory if (TTD.runtime == UNSCHEDULE) { master_sched_unschedule(procID, &activeJob); deallocate_stack(TTD.yarn_current->stackBase); pool_free(get_yarn_pool(), TTD.yarn_current); } else if (TTD.shouldSuspend) { TTD.yarn_current->isSuspended = 1; TTD.yarn_current->suspensionCore = procID; memcpy(&(TTD.yarn_current->suspensionJob), &activeJob, sizeof(activeJob)); } else { master_sched_reschedule(procID, &activeJob); } deadSleepTime = YARNS_DEAD_SLEEP_TIME; } #ifdef BASE_CONTEXT_NEEDS_STACK deallocate_stack(stackRoot); #endif }