Exemple #1
0
/*
 * Prototype OS that creates threads and semaphores.
 */
void os_primitive()
{
    unsigned int i;
    tcb *thread_pointer;

    // Create the semaphores
    full = mysem_create(0);
    empty = mysem_create(BUFFER_SIZE);
    mutex = mysem_create(1);

    // Create the threads
    for (i = 0; i < NUM_THREADS; i++)
    {
        thread_pointer = mythread_create(i, 4096, mythread);   // 4B * 4096 entries = 16KB
        mythread_start(thread_pointer);
        mythread_join(thread_pointer);
    }

    if ( start_alarm_succeed() )
        printf ("Start the alarm successfully\n");
    else
        printf ("Unable to start the alarm\n");

    /* an endless while loop */
    while (1)
    {
        printf ("This is the OS primitive for my exciting CSE351 course projects!\n");

        /* delay printf for a while */
        for (i = 0; i < 5*MAX; i++);
    }
}
// Our operating system prototype
void prototype_os()
{
	nextBufferIndex = 0;
	full = mysem_create(0);
	empty = mysem_create(BUFFER_SIZE);
	mutex = mysem_create(1);
	int i = 0;
	running_thread[1] = NULL;
	TCB *threads[NUM_THREADS];
	for (i = 0; i < NUM_THREADS; i++)
	{
		// Here: call mythread_create so that the TCB for each thread is created
		TCB *tcb = (TCB *) malloc(sizeof(TCB));
		if (i % 2 == 0)
			mythread_create(tcb, &consumer, i);
		else
			mythread_create(tcb, &producer, i);
		threads[i] = tcb;
	}
	// Here: initialize the timer and its interrupt handler as is done in Project I
	alt_alarm * myAlarm;
	alt_alarm_start( &myAlarm, ALARMTICKS(QUANTUM_LENGTH), &mythread_handler, NULL);
	for (i = 0; i < NUM_THREADS; i++)
	{
		// Here: call mythread_join to suspend prototype_os
		mythread_join(i);
	}

	while (TRUE)
	{
		alt_printf ("This is the OS prototype for my exciting CSE351 course projects!\n");
		int j = 0;
		for (j = 0 ; j < MAX * 10; j++);
	}
}
Exemple #3
0
void rtsp_buildMenu(interfaceMenu_t *pParent)
{
	int rtsp_icons[4] = { 0, 0, statusbar_f3_add, statusbar_f4_enterurl };

	createListMenu(&rtspStreamMenu, _T("MOVIE_LIST"), thumbnail_vod, rtsp_icons, pParent,
					   /* interfaceInfo.clientX, interfaceInfo.clientY,
					   interfaceInfo.clientWidth, interfaceInfo.clientHeight,*/ interfaceListMenuIconThumbnail,
					   NULL, NULL, NULL);
	interface_setCustomKeysCallback((interfaceMenu_t*)&rtspStreamMenu, rtsp_keyCallback);

	mysem_create(&rtsp_semaphore);

	memset(&stream_info, 0, sizeof(rtsp_stream_info));

#ifdef ENABLE_TEST_MODE
	{
		char desc[MENU_ENTRY_INFO_LENGTH];
		strcpy(stream_info.streamname, "a.mpg");
		strcpy(stream_info.ip, "192.168.200.1");
		stream_info.port = 554;
		stream_info.custom_url = 1;
		sprintf(desc, "%s: %s", _T("MOVIE"), "rtsp://192.168.200.1:554/a.mpg");
		interface_playControlSetup(rtsp_play_callback, CHANNEL_INFO_SET(0, CHANNEL_CUSTOM), interfacePlayControlStop|interfacePlayControlPause|interfacePlayControlRewind|interfacePlayControlFastForward|interfacePlayControlPlay|interfacePlayControlPrevious|interfacePlayControlNext, desc, thumbnail_vod);
		/*sprintf(desc, "%s: rtsp://%s:%d/%s", _T("MOVIE"), stream_info.ip, stream_info.port, stream_info.streamname);
		interface_playControlSetup(rtsp_play_callback, NULL, CHANNEL_INFO_SET(0, CHANNEL_CUSTOM), interfacePlayControlStop|interfacePlayControlPause|interfacePlayControlRewind|interfacePlayControlFastForward|interfacePlayControlPlay, desc, IMAGE_DIR "thumbnail_vod.png", 0);*/
	}
#endif // #ifdef ENABLE_TEST_MODE

	//rtsp_fillMenu();
}
Exemple #4
0
int event_create(pmysem_t* semaphore)
{
    int retValue;

    retValue = mysem_create(semaphore);

    if (retValue == 0) 
    {
        (*semaphore)->semCount = 0;
    }

    return retValue;
}