Пример #1
0
void kmutex1_main( void )
{
    CYG_TEST_INIT();

    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kmutex1-0",
        (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);

    cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "kmutex1-1",
        (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
    cyg_thread_resume(thread[1]);

    cyg_thread_create(4, entry2 , (cyg_addrword_t)2, "kmutex1-2",
        (void *)stack[2], STACKSIZE, &thread[2], &thread_obj[2]);
    cyg_thread_resume(thread[2]);

    cyg_mutex_init( &m0 );
    cyg_mutex_init( &m1 );

    cyg_cond_init( &cvar0, &m0 );
    cyg_cond_init( &cvar1, &m0 );
    cyg_cond_init( &cvar2, &m1 );

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
Пример #2
0
void vjpegInit(void)
{
#ifndef ECOS
    tt_rmutex_init(&g_vpJPEG.mtLock);
    tt_rmutex_init(&g_vpJPEG.mtLockEncoder);
    tt_rmutex_init(&g_vpJPEG.mtLockDecoder);
    
    tt_sem_init(&g_vpJPEG.semEncoder, 1);
    tt_sem_init(&g_vpJPEG.semDecoder, 1);
	tt_sem_down(&g_vpJPEG.semEncoder);
	tt_sem_down(&g_vpJPEG.semDecoder);
#else
    cyg_mutex_init(&g_vpJPEG.mtLock);
    cyg_mutex_init(&g_vpJPEG.mtLockEncoder);
    cyg_mutex_init(&g_vpJPEG.mtLockDecoder);
    
    cyg_semaphore_init(&g_vpJPEG.semEncoder, 1);
    cyg_semaphore_init(&g_vpJPEG.semDecoder, 1);
	cyg_semaphore_wait(&g_vpJPEG.semEncoder);
	cyg_semaphore_wait(&g_vpJPEG.semDecoder);
#endif
    
    g_vpJPEG.nRefCount = 0;
    g_vpJPEG.nRefCount_Encoder = 0;
    g_vpJPEG.nRefCount_Decoder = 0;
        
    g_vpJPEG.pJPEGEncodeBuffer = NULL;
    
   	listInit (&g_vpJPEG.listEncodedJPEG);
   	
   	g_vpJPEG.nJPEGQua = 2;
   	g_vpJPEG.bOnTheFly = TRUE;
   	g_vpJPEG.nOnTheFlyCount = 0;

#ifndef ECOS
    sysInstallISR(IRQ_LEVEL_1, IRQ_JPEG, (void*)jpegIntHandler);
#else
	cyg_interrupt_disable();
	cyg_interrupt_create(IRQ_JPEG, IRQ_LEVEL_1, NULL, &jpegIntHandler, &jpegIntHandler_DSR,
				&(g_vpJPEG.cygIntrHandle), &(g_vpJPEG.cygIntrBuffer));
	cyg_interrupt_attach(g_vpJPEG.cygIntrHandle);
	cyg_interrupt_unmask(IRQ_JPEG);
	cyg_interrupt_enable();
#endif

    jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_COMPLETE_INTERRUPT, vjpegEncoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_COMPLETE_INTERRUPT, vjpegDecoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_ERROR_INTERRUPT, vjpegDecoderErr_Callback);
	if(g_vpJPEG.bOnTheFly == TRUE)
	{
		jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_SWONTHEFLY_WAIT_INTERRUPT, vjpegOnTheFlyCom_Callback);
	}
		
    bJPEGInit = TRUE;
}
Пример #3
0
usbTerm::usbTerm(cyg_uint32 b_size, const char * const prompt_str) : cTerm(b_size, prompt_str)
{
	mBannerFlag = false;

	cyg_thread_create(USB_PRIORITY,
			usbTerm::rx_thread_func,
			(cyg_addrword_t)this,
			(char *)"usbTerm",
			mRXStack,
			USB_STACK_SIZE,
			&mRXThreadHandle,
			&mRXThread);

	cyg_thread_resume(mRXThreadHandle);


	mUSBRXlen = 0;
	mCMDidx = 0;
	mUSBstatus = unknown;

	cyg_mutex_init(&mUSBmutex);
	cyg_cond_init(&mUSBrxCond, &mUSBmutex);



	USBD_Init(&USB_OTG_dev,
			USB_OTG_FS_CORE_ID,
			&USR_desc,
			&USBD_CDC_cb,
			&USR_cb);

}
Пример #4
0
static int 
e_mutex_new(lua_State *L)
{
    cyg_mutex_t *mx;
    mx = (cyg_mutex_t *) lua_newuserdata(L, sizeof(cyg_mutex_t)); 
    cyg_mutex_init(mx);
    set_user_data_type(L, E_MUTEX);
    return 1;
}
Пример #5
0
void cyg_user_start(void)
{
    cyg_mutex_init(&mut_t);
    resinit();
    cyg_thread_create(5,simple_programA,(cyg_addrword_t) 0,
                      "THREAD A", (void *)stack[0], STACK_MAX, &simple_threadA,
                      &thread_s[0]);
    cyg_thread_create(4,simple_programB,(cyg_addrword_t) 1,
                      "THREAD B", (void *)stack[1], STACK_MAX, &simple_threadB,
                      &thread_s[1]);
    cyg_thread_resume(simple_threadA);
    cyg_thread_resume(simple_threadA);
}
Пример #6
0
// Called to initialize structures used by timeout functions
void
cyg_tsleep_init(void)
{
    int i;
    struct wakeup_event *ev;
    // Create list of "wakeup event" semaphores
    for (i = 0, ev = wakeup_list;  i < CYGPKG_NET_NUM_WAKEUP_EVENTS;  i++, ev++) {
        ev->chan = 0;
        cyg_semaphore_init(&ev->sem, 0);
    }
    // Initialize the mutex and thread id:
    cyg_mutex_init( &splx_mutex );
    splx_thread = 0;
}
void	_spinlock_init(_lock *plock)
{

#ifdef PLATFORM_LINUX

	//eason 20100210 spin_lock_init(plock);
	cyg_mutex_t * mut_t = plock;
	cyg_mutex_init(mut_t);	

#endif	
	
#ifdef PLATFORM_WINDOWS

	NdisAllocateSpinLock(plock);

#endif
	
}
Пример #8
0
/* we install our own startup routine which sets up threads */
void test_ecos_simple_program(void)
{
    printf("Entering twothreads' cyg_user_start() function\n");

#if 1
    cyg_mutex_init(&cliblock);
#endif

    cyg_thread_create(4, simple_program, (cyg_addrword_t) 0,
            "Thread A", (void *) stack[0], 4096,
            &simple_threadA, &thread_s[0]);
    cyg_thread_create(4, simple_program, (cyg_addrword_t) 1,
            "Thread B", (void *) stack[1], 4096,
            &simple_threadB, &thread_s[1]);

    cyg_thread_resume(simple_threadA);
    cyg_thread_resume(simple_threadB);
}
Пример #9
0
// init
void reconos_hwsched_init() {
    reconos_hwthread_list = NULL;
    num_global_yield_requests = 0;

    cyg_mutex_init(&reconos_hwsched_mutex);
    cyg_cond_init(&reconos_hwsched_condvar, &reconos_hwsched_mutex);

    cyg_thread_create( 0, 
                       reconos_hw_scheduler, 
                       (cyg_addrword_t)NULL, 
                       "RECONOS_HW_SCHEDULER", 
                       reconos_hwsched_stack,
                       RECONOS_HWSCHED_STACK_SIZE,
                       &reconos_hwsched_thread_handle,
                       &reconos_hwsched_thread
                    );

    cyg_thread_resume( reconos_hwsched_thread_handle );
};
Пример #10
0
/* we install our own startup routine which sets up threads */
void cyg_user_start(void)
{
  
//  FILE *f = fopen("/dev/ser1", "w");
//  stdout = f;			// Redirect stdout
  
  printf("\r\nEntering twothreads' cyg_user_start() function\r\n");

 cyg_mutex_init(&cliblock);

 cyg_thread_create(4, simple_program, (cyg_addrword_t) 0,
	"Thread A", (void *) stack[0], 4096,
	&simple_threadA, &thread_s[0]);
 cyg_thread_create(4, simple_program, (cyg_addrword_t) 1,
	"Thread B", (void *) stack[1], 4096,
	&simple_threadB, &thread_s[1]);

 cyg_thread_resume(simple_threadA);
 cyg_thread_resume(simple_threadB);
}
Пример #11
0
int main( int argc, char *argv[] )
{
	int i;
	HAL_DCACHE_ENABLE();

	printf("begin mutex_test_ecos\n");

	cyg_mutex_init(&mutex);
	cyg_mutex_lock(&mutex);

	printf("creating hw thread... ");
	
	cyg_thread_resume(ECOS_HWT_CREATE(0,0,thread_resources));
	printf("ok\n");
	
	for(i = 0; i < 10; i++){
		unsigned long ticks = cyg_current_time();
		//printf("current time = %ld ticks\n",ticks); // XXX remove
		cyg_mutex_unlock(&mutex);
		while(cyg_current_time() - ticks < 10); // wait for 0.1 seconds
		cyg_mutex_lock(&mutex);
		ticks = cyg_current_time() - ticks;
		//printf("delta t = %ld ticks\n", ticks); // XXX remove
		
		printf("mutex lock and release by hwthread: ");
		if(ticks > 20 && ticks < 40){
			printf("success\n");
		}
		else if(ticks <= 20){
			printf("too early\n"); // should not happen
		}
		else {
			printf("too late\n"); // should not happen
		}
		cyg_thread_delay(50);
	}
	
	printf("mutex_test_ecos done.\n");
	
	return 0;
}
Пример #12
0
///
/// Initialize the ICAP
///
void icap_init(void){
        CYG_REPORT_FUNCTION();

        XStatus Status;

        icap_config = XHwIcap_LookupConfig(HWICAP_DEVICEID);
        Status = XHwIcap_CfgInitialize(&HwIcap, &icap_config, icap_config->BaseAddress);

        if (Status != XST_SUCCESS)
        {
            switch (Status) {
                case XST_INVALID_PARAM:
                    diag_printf("HWICAP: invalid parameter\n");
                    break;
                case XST_FAILURE:
                    diag_printf("HWICAP: failure\n");
                    break;
                case XST_DEVICE_IS_STARTED:
                    diag_printf("HWICAP: device already started\n");
                    break;
                case XST_DEVICE_NOT_FOUND:
                    diag_printf("HWICAP: device not found\n");
                    break;
                default:
                    diag_printf("HWICAP: failed with return value %d\n", Status);
            }
            CYG_FAIL("failed to initialize icap\naborting\n");
        }

        // Run self test
        Status = XHwIcap_SelfTest(&HwIcap);
        if (Status != XST_SUCCESS) {
            CYG_FAIL("HWICAP: self-test failed\n");
        }

        cyg_mutex_init(&icap_mutex);

        CYG_REPORT_RETURN();
}
Пример #13
0
/*
* Initialize internal resources used in the timer module. It must be called
* before any other timer function calls. The param 'timer_entries' is used
* to pre-allocate fixed number of timer entries.
*/
int
bcm_timer_module_init(int timer_entries, bcm_timer_module_id *module_id)
{
	int size = timer_entries*sizeof(ecos_timer_entry_t);
	ecos_timer_list_t *list;
	int i;

	TIMERDBG("entries %d", timer_entries);

	/* alloc fixed number of entries upfront */
	list = malloc(sizeof(ecos_timer_list_t)+size);
	if (list == NULL)
		goto exit0;

	cyg_mutex_init(&(list->lock));
	list->flags = TIMER_LIST_FLAG_NONE;
	list->entry = (ecos_timer_entry_t *)(list + 1);
	list->entries = timer_entries;
	TIMERDBG("entry %08x", list->entry);

	/* init the timer entries to form two list - freed and used */
	list->freed = NULL;
	list->used = NULL;
	memset(list->entry, 0, timer_entries*sizeof(ecos_timer_entry_t));

	for (i = 0; i < timer_entries; i ++)
	{
		put_entry(&list->freed, &list->entry[i]);
	}
	list->flags = TIMER_LIST_FLAG_INIT;
	*module_id = (bcm_timer_module_id)list;

	TIMERDBG("list %08x freed %08x used %08x", list, list->freed, list->used);
	return 0;

exit0:
	return -1;
}
Пример #14
0
void
cyg_start(void)
{
    CYG_TEST_INIT();
    
    cyg_mutex_init(&can_lock);
    cyg_cond_init(&can_wait, &can_lock);
    
    //
    // create the main thread
    //
    cyg_thread_create(4, can_thread, 
                        (cyg_addrword_t) 0,
                        "can_thread", 
                        (void *) can_thread_data.stack, 
                        1024 * sizeof(long),
                        &can_thread_data.hdl, 
                        &can_thread_data.obj);
                        
    cyg_thread_resume(can_thread_data.hdl);
    
    cyg_scheduler_start();
}
Пример #15
0
void 
jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
{
     struct super_block *sb=OFNI_BS_2SFFJ(c);
     
     CYG_ASSERTC(c);
     CYG_ASSERTC(!sb->s_gc_thread_handle);
     
     cyg_flag_init(&sb->s_gc_thread_flags);
     cyg_mutex_init(&sb->s_lock);
     
     D1(printk("jffs2_start_garbage_collect_thread\n"));
     /* Start the thread. Doesn't matter if it fails -- it's only an
      * optimisation anyway */
     cyg_thread_create(CYGNUM_JFFS2_GC_THREAD_PRIORITY,
                       jffs2_garbage_collect_thread, 
                       (cyg_addrword_t)c,"jffs2 gc thread",
                       (void*)sb->s_gc_thread_stack,
                       sizeof(sb->s_gc_thread_stack),
                       &sb->s_gc_thread_handle, 
                       &sb->s_gc_thread);
     
     cyg_thread_resume(sb->s_gc_thread_handle);
}
Пример #16
0
void resinit(void)
{
    cyg_mutex_init(&res_lock);
    cyg_cond_init(&res_wait, &res_lock);
}
Пример #17
0
void cyg_recursive_mutex_init( cyg_recursive_mutex_t *mx )
{
  cyg_mutex_init(&(mx->mutex));
  mx->owner=0;
  mx->count = 0;
}
Пример #18
0
void gw_mutex_init(gw_mutex_t *mutex)
{
	cyg_mutex_init(mutex);
}
Пример #19
0
void controller( cyg_addrword_t id )
{
    cyg_priority_t pri;
    int i;

    cyg_mutex_init( &worker_mutex );
    cyg_cond_init( &worker_cv, &worker_mutex );
    
// 1 thread, it is running, it calls BREAKME();
//  +++ Thread status returned:
//  +++ 1 thread, running, is the current one
    
    breakme();

// Create N more threads; they are all suspended after creation.  Adjust
// the priorities of all the threads to lower than the controlling thread.
// Make them all be distinct priorities as far as possible.  BREAKME();
//  +++ 1 thread, running, + N suspended ones of different prios.

    for( i = 1; i < THREADS; i++ )
    {
        pri = CONTROLLER_PRI_HI + 1 + i % WORKER_PRI_RANGE;

        cyg_thread_create(pri, worker, (cyg_addrword_t)i, "worker",
                          (void *)(&thread_stack[i]), STACKSIZE,
                          &thread_handle[i], &thread[i]);

    }

    breakme();

// Adjust the priorities of all the threads to lower than the controlling
// thread.  Make them all be THE SAME priority.  BREAKME();
//  +++ 1 thread, running, + N suspended ones of same prio.

    for( i = 1; i < THREADS; i++ )
    {
        cyg_thread_set_priority( thread_handle[i], WORKER_PRI );
    }

    breakme();
    
// Release all the N threads, BREAKME();
//  +++ 1 thread, running, + N ready ones of same prio.

    for( i = 1; i < THREADS; i++ )
    {
        cyg_thread_resume( thread_handle[i] );
    }

    breakme();

// Adjust the priorities of all the threads, lower than the controlling
// thread.  Make them all be distinct priorities as far as possible.
// BREAKME();
//  +++ 1 thread, running, + N ready ones of different prios.

    for( i = 1; i < THREADS; i++ )
    {
        pri = CONTROLLER_PRI_HI + 1 + i % WORKER_PRI_RANGE;
        
        cyg_thread_set_priority( thread_handle[i], pri );
    }

    breakme();
    
// Command all the N threads to sleep; switch my own priority to lower
// than theirs so that they all run and sleep, then I get back in and
// BREAKME();
// +++ 1 thread, running, + N sleeping ones of different prios.

    worker_state = WORKER_STATE_WAIT;

    cyg_thread_set_priority( thread_handle[0], CONTROLLER_PRI_LO );

    breakme();
    
// Make them all be THE SAME priority; BREAKME();
//  +++ 1 thread, running, + N sleeping ones of same prio.

    for( i = 1; i < THREADS; i++ )
    {
        cyg_thread_set_priority( thread_handle[i], WORKER_PRI );
    }

    breakme();

// Wake them all up, they'll loop once and sleep again; I get in and
// BREAKME();
//  +++ 1 thread, running, + N sleeping ones of same prio.

    cyg_cond_broadcast( &worker_cv );

    breakme();

// Adjust the priorities of all the threads, higher than the controlling
// thread.  Make them all be distinct priorities as far as possible.
// BREAKME();
//  +++ 1 thread, running, + N sleeping ones of different prios.

    for( i = 1; i < THREADS; i++ )
    {
        pri = CONTROLLER_PRI_HI + 1 + i % WORKER_PRI_RANGE;
        
        cyg_thread_set_priority( thread_handle[i], pri );
    }

    breakme();

// Wake them all up, they'll loop once and sleep again; I get in and
// BREAKME();
//  +++ 1 thread, running, + N sleeping ones of different prios.

    cyg_cond_broadcast( &worker_cv );

    breakme();

// Set them all the same prio, set me to the same prio, BREAKME();
//  +++ 1 running, + N sleeping, *all* the same prio.

    for( i = 0; i < THREADS; i++ )
    {
        cyg_thread_set_priority( thread_handle[i], WORKER_PRI );
    }

    breakme();

// Wake them all up, they'll loop once and sleep again; I get in and
// BREAKME(); repeatedly until they have all slept again.
//  +++ 1 running, + some sleeping, some ready, *all* the same prio.

    cyg_cond_broadcast( &worker_cv );

//    cyg_thread_yield();
    
    do
    {
        breakme();
        
    } while( workers_asleep != THREADS-1 ); 

    breakme();
    
// Suspend some of the threads, BREAKME();
//  +++ 1 running, + some sleeping, some suspended, *all* the same prio.

    for( i = 1; i < THREADS; i++ )
    {
        // suspend every 3rd thread
        if( 0 == (i % 3) ) cyg_thread_suspend( thread_handle[i] );
    }

    breakme();


// Change the prios all different, change my prio to highest , BREAKME();
//  +++ 1 running, + some sleeping, some suspended, different prios.

    cyg_thread_set_priority( thread_handle[0], CONTROLLER_PRI_HI );
        
    for( i = 1; i < THREADS; i++ )
    {
        pri = CONTROLLER_PRI_HI + 1 + i % WORKER_PRI_RANGE;
        
        cyg_thread_set_priority( thread_handle[i], pri );
    }

    breakme();
    
// Wake up all the threads, BREAKME();
//  +++ 1 running, + some ready, some suspended/ready, different prios.

    cyg_cond_broadcast( &worker_cv );

    breakme();


// Change my prio to lowest, let all the threads run, BREAKME().
//  +++ 1 running + some sleeping, some suspended/ready, different prios.

    cyg_thread_set_priority( thread_handle[0], CONTROLLER_PRI_LO );
    
    breakme();
    
// Resume all the threads, BREAKME();
//  +++ 1 running, + N ready, different prios.

    for( i = 1; i < THREADS; i++ )
    {
        cyg_thread_resume( thread_handle[i] );
    }
    
    breakme();
    
// Command some of the N threads to call BREAKME(); themselves (then sleep
// again).  Change my prio to low, so that they all get to run and hit the
// breakpoint.
//  +++ A different one running every time, others in a mixture of
//      ready and sleeping states.
    
    worker_state = WORKER_STATE_BREAK;

    cyg_cond_broadcast( &worker_cv );
    
    cyg_thread_set_priority( thread_handle[0], CONTROLLER_PRI_LO );
    
    breakme();
    
// Command all the threads to exit; switch my own priority to lower
// than theirs so that they all run and exit, then I get back in and
// BREAKME();
//  +++ 1 thread, running, + N dormant ones.

    worker_state = WORKER_STATE_EXIT;

    cyg_cond_broadcast( &worker_cv );
    
    breakme();

#if 0

// Cannot do this yet...
    
// Destroy some of the N threads to invalidate their IDs.  Re-create them
// with new IDs, so that we get IDs 1,2,4,6,8,11,12,13,14,15 in use instead
// of 1,2,3,4,5,6,7,8,9, if you see what I mean.  Do all the above again.
// Loop forever, or whatever...

#endif

    breakme();
    
    CYG_TEST_PASS_FINISH("GDB Thread test OK");
    
}
Пример #20
0
void ServerStart(void)
{

	int i, j;	

	char *pcDocRoot = "./";
	static int aiPort[] = {80, 0};
#ifndef WLAN
    FMI_CARD_DETECT_T card;
#endif	
	cyg_mutex_init(&g_ptmConfigParam);
	cyg_mutex_init(&g_ptmState);
	cyg_mutex_init(&g_ptmTimeSetting);
	cyg_mutex_init(&g_ptmWebCameraLog);
	tt_rmutex_init(&g_rmutex);
	
	{
		UINT32 uFlashTotal, uFlashFreeBegin, uFlashFreeEnd;
		GetFlashCapability(&uFlashTotal, &uFlashFreeBegin, &uFlashFreeEnd);
		diag_printf("Flash total: %d, free space [%d - %d]\n", uFlashTotal, uFlashFreeBegin, uFlashFreeEnd);
	}
	
#ifndef WLAN
	/*init the sd card*/
    //do {outpw (REG_CLKCON, inpw (REG_CLKCON) | FMICLK_EN); } while (0);
    fmiSetFMIReferenceClock(OPT_UPLL_OUT_CLOCK/3/1000);    
	fsFixDriveNumber('D', 'C', 'Z');    
    fsInitFileSystem();    
   	card.uCard = FMI_SD_CARD;		// card type
	card.uGPIO = 4;				// card detect GPIO pin
	card.uWriteProtect = 16;			// card detect GPIO pin
	card.uInsert = 0;				// 0/1 which one is insert
	card.nPowerPin = 12;				// card power pin, -1 means no power pin
	card.bIsTFlashCard = FALSE;
	fmiSetCardDetection(&card);
	fmiInitSDDevice();
	diag_printf("Init the SD Card ok!\n");
	g_StreamServer_Buf = (char*)(g_StreamServer_Buf1);
#endif
#ifdef FILESYSTEM
	/* Check if disk need to be formatted. */
	ipcCheckDisk( );	
#endif
	
	/*register reset interrupt*/
	InitResetGPIO();
	// Set HIC ready
   	outpw(REG_HICSR, inpw(REG_HICSR) & 0xFFFFFF7F);

	if (0)
	{
		int j = 0;
		for(;j<5;j++)
			init_loopback_interface(0);
	}

	
	/* 初始化camera的参数 */ 
	ResetCameraParam();    
	/* 挂载需要额外处理的URL */
	RegisterUrls();
	//GetDHCPInfo();

	/* 設置进入不同特权领域的提示语 */
	httpSetAuthPrompt(CONFIG_LOGIN_PROMPT_USER, CONFIG_LOGIN_PROMPT_ADMIN, NULL);
	/* 选择从命令行或者配置参数中设定的http端口 */
	for (i = 0; i < sizeof(g_ConfigParam.usHttpPort) / sizeof(unsigned short); i++)
	{
		if (g_ConfigParam.usHttpPort[i] == 0) g_ConfigParam.usHttpPort[i] = aiPort[i];
	}
	for (i = 0, j = 0; i < sizeof(g_ConfigParam.usHttpPort) / sizeof(unsigned short); i++)
	{
		if (g_ConfigParam.usHttpPort[i] != 0)
			aiPort[j++] = g_ConfigParam.usHttpPort[i];
	}
	aiPort[j] = 0;
	diag_printf("Port is %d,%d\n",aiPort[0],aiPort[1]);

	ResetOtherThread();
	
	{
 	   cyg_thread_create(PTD_PRIORITY, &MctestThread, (cyg_addrword_t)aiPort, "ptdMctest", ptdMctest_stack, STACKSIZE2, &ptdMctest_handle, &g_ptdMctest);
		if ( ptdMctest_handle == NULL)
		{
			fprintf(stderr, "Thread for mctest creation failed!\n");
			return;
		}
		cyg_thread_resume(ptdMctest_handle);
	}

	cyg_thread_set_priority(cyg_thread_self(), PTD_PRIORITY);
	// 开始http服务 	
	httpdStartEx(pcDocRoot, aiPort,3600, 30 * 60 * 60 , 20, OnHttpInit, OnRequestBegin);	

}