static void signal_dispatch(task_t *dest, signal_t sig) { sig_aux = (context_t*)malloc(sizeof(context_t)); sig_aux->gs = 0x001; sig_aux->fs = 0x002; sig_aux->r15 = 0x003; sig_aux->r14 = 0x004; sig_aux->r13 = 0x005; sig_aux->r12 = 0x006; sig_aux->r11 = 0x007; sig_aux->r10 = 0x008; sig_aux->r9 = 0x009; sig_aux->r8 = 0x00A; sig_aux->rsi = (uint64_t)sig; sig_aux->rdi = (uint64_t)dest; sig_aux->rbp = 0x00D; sig_aux->rdx = (uint64_t)dest->state; sig_aux->rcx = 0x00F; sig_aux->rbx = 0x010; sig_aux->rax = 0x011; sig_aux->rip = (uint64_t)sigwrapper; sig_aux->cs = 0x008; sig_aux->rflags = 0x202; sig_aux->rsp = (uint64_t) & (sig_aux->base); sig_aux->ss = 0x000; dest->stack = dest->stack - sizeof(context_t) + sizeof(uint64_t); signal_push(dest->stack, sizeof(context_t) - sizeof(uint64_t), dest->cr3, sig_aux); task_ready(dest); }
void isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) { isc_boolean_t idle1, idle2; isc_task_t *task; /* * Send '*event' to '*taskp' and then detach '*taskp' from its * task. */ REQUIRE(taskp != NULL); task = *taskp; REQUIRE(VALID_TASK(task)); XTRACE("isc_task_sendanddetach"); LOCK(&task->lock); idle1 = task_send(task, eventp); idle2 = task_detach(task); UNLOCK(&task->lock); /* * If idle1, then idle2 shouldn't be true as well since we're holding * the task lock, and thus the task cannot switch from ready back to * idle. */ INSIST(!(idle1 && idle2)); if (idle1 || idle2) task_ready(task); *taskp = NULL; }
void signal_func_witharg(task_t *dest, dka_handler func, uint64_t arg) { context_t *context; dest->stack = dest->stack - sizeof(context_t) + sizeof(uint64_t); //Eliminamos context->base que no sirve para el contexto context = (context_t *) dest->stack; context->gs = 0x001; context->fs = 0x002; context->r15 = 0x003; context->r14 = 0x004; context->r13 = 0x005; context->r12 = 0x006; context->r11 = 0x007; context->r10 = 0x008; context->r9 = 0x009; context->r8 = 0x00A; context->rsi = (uint64_t)dest->state; context->rdi = (uint64_t)dest; context->rbp = 0x00D; context->rdx = (uint64_t)func; context->rcx = (uint64_t)arg; context->rbx = 0x010; context->rax = 0x011; context->rip = (uint64_t)sigwrapper_witharg; context->cs = 0x008; context->rflags = 0x202; context->rsp = (uint64_t) & (context->base); context->ss = 0x000; task_ready(dest); }
static void task_unblock(struct k9_task * const task, int block_rc) { task_ev_wait_erase(task); task->u->blocked->rc = block_rc; task_ready(task); }
void resume_task_with_pid(int pid){ int i = SetInts(0); task_t* task = find_task_with_pid(pid); if(task != (task_t *) -1) task_ready(task); SetInts(i); }
struct k9_task * k9_task_start(struct k9_task *task) { uint32 old; old = k9_cpu_intr_dis(); task_ready(task); _k9_task_resched(); k9_cpu_intr_restore(old); return (task); }
void Directory::create_task(QString uri) { Directory_list_task* task = new Directory_list_task(uri, core); task->setAutoDelete(true); connect(task, SIGNAL(ready(File_info_list)), this, SLOT(task_ready(File_info_list))); connect(task, SIGNAL(error(QString)), this, SIGNAL(error(QString))); connect(task, SIGNAL(location_not_found()), this, SLOT(location_not_found())); QThreadPool::globalInstance()->start(task); if (Special_uri(uri).name() != Special_uri::places) { if (!watcher_created) { emit watch(uri); watcher_created = true; } } }
void isc_task_shutdown(isc_task_t *task) { isc_boolean_t was_idle; /* * Shutdown 'task'. */ REQUIRE(VALID_TASK(task)); LOCK(&task->lock); was_idle = task_shutdown(task); UNLOCK(&task->lock); if (was_idle) task_ready(task); }
static void task_switch(struct k9_task * const task) { static struct k9_task *t; if (task == cur_task) return; t = task; if (t->state == K9_TASK_STATE_READY) rdy_erase(t); if (cur_task->state == K9_TASK_STATE_RUNNING) task_ready(cur_task); if (k9_cpu_cntxt_save(&cur_task->sp) == 0) return; (cur_task = t)->state = K9_TASK_STATE_RUNNING; cur_task->cur_slice = cur_task->slice; k9_cpu_cntxt_restore(cur_task->sp); }
ISC_TASKFUNC_SCOPE void isc__task_send(isc_task_t *task0, isc_event_t **eventp) { isc__task_t *task = (isc__task_t *)task0; isc_boolean_t was_idle; /* * Send '*event' to 'task'. */ REQUIRE(VALID_TASK(task)); XTRACE("isc_task_send"); /* * We're trying hard to hold locks for as short a time as possible. * We're also trying to hold as few locks as possible. This is why * some processing is deferred until after the lock is released. */ LOCK(&task->lock); was_idle = task_send(task, eventp); UNLOCK(&task->lock); if (was_idle) { /* * We need to add this task to the ready queue. * * We've waited until now to do it because making a task * ready requires locking the manager. If we tried to do * this while holding the task lock, we could deadlock. * * We've changed the state to ready, so no one else will * be trying to add this task to the ready queue. The * only way to leave the ready state is by executing the * task. It thus doesn't matter if events are added, * removed, or a shutdown is started in the interval * between the time we released the task lock, and the time * we add the task to the ready queue. */ task_ready(task); } }
void isc_task_detach(isc_task_t **taskp) { isc_task_t *task; isc_boolean_t was_idle; /* * Detach *taskp from its task. */ REQUIRE(taskp != NULL); task = *taskp; REQUIRE(VALID_TASK(task)); XTRACE("isc_task_detach"); LOCK(&task->lock); was_idle = task_detach(task); UNLOCK(&task->lock); if (was_idle) task_ready(task); *taskp = NULL; }
void corejob_end(DL_STATE *page, task_t **complete, Bool failure_handled) { task_group_t *root_group = task_group_root() ; corecontext_t *context = get_core_context() ; error_context_t error = ERROR_CONTEXT_INIT, *olderror ; corejob_t *job = page->job ; VERIFY_OBJECT(job, CORE_JOB_NAME) ; /* Suppress errors from this function and sub-functions. We're able to cope with failure by joining immediately. */ olderror = context->error ; context->error = &error ; /* The job's task group is now complete. If we pipeline jobs, this means that we can run tasks in the job through task_helper_locked(). */ task_group_close(job->task_group) ; if ( complete != NULL ) { *complete = NULL ; #ifdef PIPELINE_JOBS #ifdef DEBUG_BUILD pipeline_jobs = (debug_dl & DEBUG_DL_PIPELINE_JOBS) != 0 ; #endif if ( pipeline_jobs ) { task_group_t *job_group = task_group_acquire(job->task_group) ; if ( task_group_create(&job->join_group, TASK_GROUP_COMPLETE, root_group, NULL) ) { task_group_ready(job->join_group) ; if ( task_create(complete, NULL /*specialiser*/, NULL /*spec args*/, NULL /*no worker*/, NULL /*args*/, &corejob_finalise, job->join_group, SW_TRACE_JOB_COMPLETE) ) { /* If successful, this next call atomically sets the task args to the job object: */ Bool transferred = task_group_set_joiner(job_group, *complete, job_group) ; task_ready(*complete) ; task_group_close(job->join_group) ; if ( transferred ) goto done ; task_release(complete) ; } task_group_cancel(job->join_group, context->error->new_error) ; (void)task_group_join(job->join_group, NULL) ; task_group_release(&job->join_group) ; } task_group_release(&job_group) ; } #endif /* PIPELINE_JOBS */ } /* Ignore the error return value; if the job is failed because of an asynchronous flush, the job's failure field is set. */ (void)dl_pipeline_flush(1, failure_handled) ; /* We failed to create a separate completion task for this job. We need to join the job group synchronously. */ (void)task_group_join(job->task_group, NULL) ; #ifdef PIPELINE_JOBS done: #endif context->error = olderror ; task_group_release(&root_group) ; /* Don't increment job number on a font query etc... */ if ( job->has_output ) ++page->job_number ; corejob_release(&page->job) ; }