예제 #1
0
void testget()
{
    uint64_t cguid = 1;
    SDF_container_type_t ctype = SDF_BLOCK_CONTAINER;

    for (int blockNum = 0; blockNum < numBlocks*2; blockNum++) {
        local_key_t *lkey = get_local_block_key(blockNum);
        DirEntry *entry = HomeDir_get(homedir, cguid, ctype, lkey);
        // {{
        if (blockNum < numBlocks) {
            plat_assert_always(entry);
            fthWaitEl_t *wait = reqq_lock(entry->q); // LOCK REQQ
            fthThread_t *top = reqq_peek(entry->q);
            plat_assert_always(top == fthSelf());
            fthThread_t *self = reqq_dequeue(entry->q);
            plat_assert_always(self == fthSelf());
            reqq_unlock(entry->q, wait); // UNLOCK REQQ
            if (NULL != (top = reqq_peek(entry->q))) {
                fthResume(top, 0);
                printf("Thread 1: yielding after setting thread 2 to run for block=%u\n", blockNum);
                fthYield(1);
            }
        }
        // }}
        free_local_key(lkey);
    }
    printf("Thread 1: Got %d blocks from the directory\n", numBlocks);
}
void testget(uint64_t seq) {
	uint64_t cguid = 1;
	SDF_container_type_t ctype = SDF_BLOCK_CONTAINER;

	for (int i = 0; i < niterator; i++) {
		local_key_t *lkey = get_local_block_key(0);
		DirEntry *entry = HomeDir_get(homedir, cguid, ctype, lkey);

		if (entry == NULL)
		{
			(void) __sync_fetch_and_add(&nmisses, 1);
			printf("Miss\n");
			continue;
		}
		else
		{
			(void) __sync_fetch_and_add(&ngets, 1);
			(void) __sync_fetch_and_add(&nhits, 1);
		}
		// {{
		/*if (blockNum < numBlocks) {*/
		fthWaitEl_t *wait = reqq_lock(entry->q); // LOCK REQQ
		fthThread_t *top = reqq_peek(entry->q);
		plat_assert_always(top != 0);
//		plat_assert_always(top == fthSelf());
		fthThread_t *self = reqq_dequeue(entry->q);
		plat_assert_always(self != 0);
//		plat_assert_always(self == fthSelf());
		reqq_unlock(entry->q, wait); // UNLOCK REQQ
/*		if (NULL != (top = reqq_peek(entry->q))) {
			fthResume(top, 0);
			printf(
					"Thread 1: yielding after setting thread 2 to run for block=%u\n",
					blockNum);
			fthYield(1);
		}*/
		//}
		// }}
		free_local_key(lkey);
	}
}