Esempio n. 1
0
int main()
{
	struct SLL *head =  NULL;
	
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	push(&head, 0);
	push(&head, 1);
	struct SLL *head2 =  NULL;
	printSLL(head);
	split(&head, &head2);
	
	printSLL(head);
	printSLL(head2);
	
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    struct timeval tv_start;
    struct timeval tv_end;
    gettimeofday(&tv_start, NULL);
    
    if (argc != 4)
    {
        fprintf(stderr, "usage: a.out numInts numBlanks numFAItems\n");
        exit(0);
    }
    int N = atoi(argv[1]);
    int K = atoi(argv[2]);
    int X = atoi(argv[3]);
    fprintf(stderr, "N = %d K = %d X = %d\n", N, K, X);
    assert(!(N%2) && "N is not even");
    assert(X > 0);
#ifdef _FORCE_FAIL
    srand(time(NULL));
    randval = rand() % N;
#endif

    // Initialize Atlas
    NVM_Initialize();
    // Create an Atlas persistent region
    sll_rgn_id = NVM_FindOrCreateRegion("sll_ll", O_RDWR, NULL);
    
    int i;
    for (i = 1; i < N/2+1; ++i) insertPass1(i, K, X);
    InsertAfter = SLL;

    for (i=N/2+1; i < N; i += X) insertPass2(i, K, X);
    int total_inserted = i - 1;
    insertPass2(i, K,  N - total_inserted);

    fprintf(stderr, "Sum of elements is %ld\n", printSLL());

    // Close the Atlas persistent region
    NVM_CloseRegion(sll_rgn_id);
    // Optionally print Atlas stats
#ifdef NVM_STATS
    NVM_PrintStats();
#endif
    // Atlas bookkeeping
    NVM_Finalize();

    gettimeofday(&tv_end, NULL);

    fprintf(stderr, "time elapsed %ld us\n",
            tv_end.tv_usec - tv_start.tv_usec +
            (tv_end.tv_sec - tv_start.tv_sec) * 1000000);
    return 0;
}