Ejemplo n.º 1
0
Archivo: mk.c Proyecto: 99years/plan9
void
mk(char *target)
{
	Node *node;
	int did = 0;

	nproc();		/* it can be updated dynamically */
	nrep();			/* it can be updated dynamically */
	runerrs = 0;
	node = graph(target);
	if(DEBUG(D_GRAPH)){
		dumpn("new target\n", node);
		Bflush(&bout);
	}
	clrmade(node);
	while(node->flags&NOTMADE){
		if(work(node, (Node *)0, (Arc *)0))
			did = 1;	/* found something to do */
		else {
			if(waitup(1, (int *)0) > 0){
				if(node->flags&(NOTMADE|BEINGMADE)){
					assert(/*must be run errors*/ runerrs);
					break;	/* nothing more waiting */
				}
			}
		}
	}
	if(node->flags&BEINGMADE)
		waitup(-1, (int *)0);
	while(jobs)
		waitup(-2, (int *)0);
	assert(/*target didnt get done*/ runerrs || (node->flags&MADE));
	if(did == 0)
		Bprint(&bout, "mk: '%s' is up to date\n", node->name);
}
Ejemplo n.º 2
0
int main(void)
{
    /* This tests that bmo_uid properly provides unique values across multiple
    threads.
    We can't force a race condition but we can try to run as many hardware
    threads as available over billions of calls which would _likely_ fail
    if bmo_uid() was racy.
    If only one hardware thread is available, just warn, as a single hardware
    thread will never cause a race.
    */
    int nthreads = nproc();
    if (getenv("TRAVIS") || getenv("JENKINS_HOME")) {
    // CI builds time out because there are more physical processor in the host
    // than the guest
        nthreads = MIN(4, nthreads);
    }
    uint64_t iter = 10000000;
    int i = 0;
    if (nthreads == 1) {
        fprintf(
            stderr,
            "WARNING only one hardware thread available for multithreaded test"
        );
    }
    assert(nthreads < MAX_THREADS);
    printf("running bmo_uid() over %d threads\n", nthreads);
    spawn_test_threads(nthreads, &iter);

    assert(bmo_uid() == (iter * nthreads));
    assert(BMO_ATOM_INC(&i) - BMO_ATOM_INC(&i) == -1);

    return 0;
}
Ejemplo n.º 3
0
Archivo: prim.c Proyecto: l0stman/loot
/* Install the primitive procedures in the environment */
void
instprim(env_t *envp)
{
        int i;

        for (i = 0; i < NELEMS(plst); i++)
                install(plst[i].n, nproc(nprim(plst[i].n, plst[i].pp)), envp);
}
Ejemplo n.º 4
0
CVZContainer::operator QString() const
{
    QString res = ctid() + " ";
    if (status() == Running) {
        res += QString::number(nproc());
        res += " running";
    } else {
        res += "-";
        res += " stopped";
    }

    return res;
}
Ejemplo n.º 5
0
void process_files(GSList *files, struct scan_opts *opts) {
    GThreadPool *pool;
    GThread *progress_bar_thread;

    int started = 0;

    // Start the progress bar thread. It misuses progress_mutex and
    // progress_cond to signal when it is ready.
    g_mutex_lock(progress_mutex);
    progress_bar_thread = g_thread_create(print_progress_bar,
                                          &started, TRUE, NULL);
    while (!started)
        g_cond_wait(progress_cond, progress_mutex);
    g_mutex_unlock(progress_mutex);

    pool = g_thread_pool_new((GFunc) init_state_and_scan_work_item,
                             opts, nproc(), FALSE, NULL);
    g_slist_foreach(files, (GFunc) init_state_and_scan, pool);
    g_thread_pool_free(pool, FALSE, TRUE);
    g_thread_join(progress_bar_thread);
}