Exemplo n.º 1
0
Arquivo: main.c Projeto: xsmart/sdk
int main(int argc, char* argv[])
{
	locker_test();
	atomic_test();
	spinlock_test();
	event_test();
#if !defined(OS_MAC)
	semaphore_test();
#endif

	stack_test();

#if defined(OS_WINDOWS)
//	rtsp_header_range_test();
	rtsp_header_session_test();
	rtsp_header_rtp_info_test();
	rtsp_header_transport_test();

	sdp_test();
	sdp_a_fmtp_test();
	sdp_a_rtpmap_test();

	url_test();
	unicode_test();
	utf8codec_test();
	thread_pool_test();

	ip_route_test();

	//aio_socket_test();
	//systimer_test();
	system("pause");
#endif
	return 0;
}
Exemplo n.º 2
0
// Setup code for APs
void
mp_main(void)
{
	// We are in high EIP now, safe to switch to kern_pgdir 
	lcr3(PADDR(kern_pgdir));
	cprintf("SMP: CPU %d starting\n", cpunum());

	lapic_init();
	env_init_percpu();
	trap_init_percpu();
	xchg(&thiscpu->cpu_status, CPU_STARTED); // tell boot_aps() we're up

#ifdef USE_TICKET_SPIN_LOCK
	spinlock_test();
#endif

	// Now that we have finished some basic setup, call sched_yield()
	// to start running processes on this CPU.  But make sure that
	// only one CPU can enter the scheduler at a time!
	//
	// Your code here:
	lock_kernel();
	sched_yield();
	// Remove this after you finish Exercise 4
	//for (;;);
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
    if (argc < 2)
	fail("To few arguments for test case");

#ifndef ETHR_NO_THREAD_LIB
    {
	char *testcase;

	send_my_pid();

	testcase = argv[1];

	if (ethr_init(NULL) != 0 || ethr_late_init(NULL) != 0)
	    fail("Failed to initialize the ethread library");

	if (strcmp(testcase, "create_join_thread") == 0)
	    create_join_thread_test();
	else if (strcmp(testcase, "equal_tids") == 0)
	    equal_tids_test();
	else if (strcmp(testcase, "mutex") == 0)
	    mutex_test();
	else if (strcmp(testcase, "try_lock_mutex") == 0)
	    try_lock_mutex_test();
	else if (strcmp(testcase, "cond_wait") == 0)
	    cond_wait_test();
	else if (strcmp(testcase, "broadcast") == 0)
	    broadcast_test();
	else if (strcmp(testcase, "detached_thread") == 0)
	    detached_thread_test();
	else if (strcmp(testcase, "max_threads") == 0)
	    max_threads_test();
	else if (strcmp(testcase, "tsd") == 0)
	    tsd_test();
	else if (strcmp(testcase, "spinlock") == 0)
	    spinlock_test();
	else if (strcmp(testcase, "rwspinlock") == 0)
	    rwspinlock_test();
	else if (strcmp(testcase, "rwmutex") == 0)
	    rwmutex_test();
	else if (strcmp(testcase, "atomic") == 0)
	    atomic_test();
	else if (strcmp(testcase, "dw_atomic_massage") == 0)
	    dw_atomic_massage_test();
	else
	    skip("Test case \"%s\" not implemented yet", testcase);

	succeed(NULL);
    }
#else /* #ifndef ETHR_NO_THREAD_LIB */
    skip("No ethread library to test");
#endif /* #ifndef ETHR_NO_THREAD_LIB */

    return 0;
}
Exemplo n.º 4
0
int thread_tests(void)
{
	mutex_test();
	semaphore_test();
	event_test();

	spinlock_test();
	atomic_test();

	thread_sleep(200);
	context_switch_test();

	preempt_test();

	join_test();

	return 0;
}
Exemplo n.º 5
0
void
i386_init(void)
{
	extern char edata[], end[];

	// Before doing anything else, complete the ELF loading process.
	// Clear the uninitialized global data (BSS) section of our program.
	// This ensures that all static/global variables start out zero.
	memset(edata, 0, end - edata);

	// Initialize the console.
	// Can't call cprintf until after we do this!
	cons_init();


	cprintf("6828 decimal is %o octal!\n", 6828);

	// cprintf("6828 decimal is %o octal!%n\n%n", 6828, &chnum1, &chnum2);
	// cprintf("pading space in the right to number 22: %-8d.\n", 22);
	// cprintf("chnum1: %d chnum2: %d\n", chnum1, chnum2);
	// cprintf("%n", NULL);
	// memset(ntest, 0xd, sizeof(ntest) - 1);
	// cprintf("%s%n", ntest, &chnum1); 
	// cprintf("chnum1: %d\n", chnum1);


	// Lab 2 memory management initialization functions
	mem_init();

	// Lab 3 user environment initialization functions
	env_init();
	trap_init();

	// Lab 4 multiprocessor initialization functions
	mp_init();
	lapic_init();

	// Lab 4 multitasking initialization functions
	pic_init();

	// Acquire the big kernel lock before waking up APs
	// Your code here:
	lock_kernel();

	// Starting non-boot CPUs
	boot_aps();

#ifdef USE_TICKET_SPIN_LOCK
	unlock_kernel();
	spinlock_test();
	lock_kernel();
#endif

	// Should always have idle processes at first.
	int i;
	for (i = 0; i < NCPU; i++)
		ENV_CREATE(user_idle, ENV_TYPE_IDLE);

#if defined(TEST)
	// Don't touch -- used by grading script!
	ENV_CREATE(TEST, ENV_TYPE_USER);
#else
	// Touch all you want.
	//ENV_CREATE(user_primes, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	//ENV_CREATE(user_yield, ENV_TYPE_USER);
	//ENV_CREATE(user_dumbfork, ENV_TYPE_USER);
	ENV_CREATE(user_hello, ENV_TYPE_USER);
#endif // TEST*

	// Schedule and run the first user environment!
	sched_yield();
}
Exemplo n.º 6
0
Arquivo: main.c Projeto: ireader/sdk
int main(int argc, char* argv[])
{
#if defined(OS_LINUX)
	struct sigaction sa;
	sa.sa_handler = SIG_IGN;
	sigaction(SIGCHLD, &sa, 0);
	sigaction(SIGPIPE, &sa, 0);
#endif

	heap_test();
	rbtree_test();
	timer_test();

	socket_test();
	locker_test();
	atomic_test();
#if defined(ATOMIC_TEST)
	atomic_test2();
#endif
	spinlock_test();
	event_test();
#if !defined(OS_MAC)
	semaphore_test();
#endif
	onetime_test();

	bits_test();
	stack_test();
	time64_test();
	base64_test();
	bitmap_test();
	hweight_test();
	ring_buffer_test();

	uri_parse_test();

#if defined(HTTP_TEST)
	http_test();
#endif

	thread_pool_test();
	task_queue_test();

	ip_route_test();

    aio_socket_test_cancel();
    aio_socket_test();
    aio_socket_test2();
    aio_socket_test3();
    aio_socket_test4();

#if defined(OS_WINDOWS)
	unicode_test();
	utf8codec_test();
	systimer_test();

	system("pause");
#endif

    return 0;
}