static void prepare(char *sample, struct start_drakvuf *start) { if (!sample && !start) return; domid_t cloneID = 0; char *clone_name = NULL; int threadid; if (!start) threadid = find_thread(); else threadid = start->threadid; while(threadid<0) { printf("Waiting for a thread to become available..\n"); sleep(1); threadid = find_thread(); } printf("Making clone %i to run %s in thread %u\n", threadid+1, sample ? sample : start->input, threadid); make_clone(xen, &cloneID, threadid+1, &clone_name); while(!clone_name || !cloneID) { printf("Clone creation failed, trying again\n"); free(clone_name); clone_name = NULL; cloneID = 0; make_clone(xen, &cloneID, threadid+1, &clone_name); } //g_mutex_lock(&prepare_lock); //uint64_t shared = xen_memshare(xen, domID, cloneID); //printf("Shared %"PRIu64" pages\n", shared); //g_mutex_unlock(&prepare_lock); if(!start && sample) { start = g_malloc0(sizeof(struct start_drakvuf)); start->input = sample; start->threadid = threadid; g_mutex_init(&start->timer_lock); } start->cloneID = cloneID; start->clone_name = clone_name; if(sample) { g_thread_pool_push(pool, start, NULL); } }
static void wq_enqueue(struct thr_info *thr, struct T1_chain *t1) { struct work *work = get_work(thr, thr->id); struct work_queue *wq; struct work_ent *we; int rolls = 0; wq = &t1->active_wq; while (42) { we = cgmalloc(sizeof(*we)); we->work = work; INIT_LIST_HEAD(&we->head); mutex_lock(&t1->lock); list_add_tail(&we->head, &wq->head); wq->num_elems++; mutex_unlock(&t1->lock); if (wq->num_elems >= t1->num_active_chips * 2) { break; } if (rolls > work->drv_rolllimit) { work = get_work(thr, thr->id); continue; } work = make_clone(work); roll_work(work); } }
static struct start_drakvuf* prepare(struct start_drakvuf* start, int _threadid) { if (shutting_down) return NULL; domid_t cloneID = 0; char* clone_name = NULL; int threadid = start ? start->threadid : _threadid; if ( shutting_down ) return NULL; printf("[%i] Making clone\n", threadid); make_clone(xen, &cloneID, threadid+1, &clone_name); while ((!clone_name || !cloneID) && !shutting_down) { printf("[%i] Clone creation failed, trying again\n", threadid); free(clone_name); clone_name = NULL; cloneID = 0; make_clone(xen, &cloneID, threadid+1, &clone_name); } if ( shutting_down ) return NULL; //uint64_t shared = xen_memshare(xen, domID, cloneID); //printf("Shared %"PRIu64" pages\n", shared); if (!start) { start = g_malloc0(sizeof(struct start_drakvuf)); start->threadid = threadid; g_mutex_init(&start->timer_lock); } start->cloneID = cloneID; start->clone_name = clone_name; start->utime = time(NULL); return start; }
/** * @brief Maintain the advert detection bots' presence and expire old * advert information periodically */ void adCloneMaintenance() { char *y; int k; if (massAdClones[0] == 0 && massAdClones[1] == 0) { if ((y = make_clone())) { massAdClones[0] = strdup(y); if ((y = make_clone())) massAdClones[1] = strdup(y); } massAdClones[2] = massAdClones[3] = massAdClones[4] = NULL; } else { if (massAdClones[0]) { sSend(":%s QUIT :%s", massAdClones[0], massAdClones[0]); massAdClones[2] = massAdClones[0]; if ((y = make_clone())) massAdClones[0] = strdup(y); } if (massAdClones[1]) { sSend(":%s QUIT :%s", massAdClones[1], massAdClones[1]); massAdClones[3] = massAdClones[1]; if ((y = make_clone())) massAdClones[1] = strdup(y); } for(k = 2; k < 4; k++) { if (massAdClones[k]) { FREE(massAdClones[k]); massAdClones[k] = 0; } } } }
triqs::arrays::vector_view <double> eigenvalues( MatrixViewType M, bool take_copy = false) { eigenelements_worker<MatrixViewType,false> W(take_copy ? make_clone(M)() : M()); W.invoke(); return W.values(); }
std::pair<array<double,1>, typename MatrixViewType::non_view_type> eigenelements( MatrixViewType M, bool take_copy =false) { eigenelements_worker<MatrixViewType, true> W(take_copy ? make_clone(M)() : M()); W.invoke(); return std::make_pair(W.values(),W.vectors()); }
std::pair<array<double,1>, typename MatrixViewType::regular_type> eigenelements( MatrixViewType const & M, bool take_copy =false) { eigenelements_worker<typename MatrixViewType::view_type, true> W(take_copy ? MatrixViewType(make_clone(M)) : M); W.invoke(); return std::make_pair(W.values(),W.vectors()); }