void levelorder(node *root) { node *temp=root; pushqueue(root) while(!isempty_q) { node *hold=pop(); printf("%d\n",hold->data); pushqueue(hold->left); pushqueue(hold->right); } }
void levelorder(node *root) { node *temp=root; pushqueue(temp); while(!isempty_q()) { node *hold=popqueue(); if(hold!=NULL) { printf("%d\n",hold->data); if(hold->left!=NULL) pushqueue(hold->left); if(hold->right!=NULL) pushqueue(hold->right); } } }
unsigned char TOS_parampost(void (*tp) (), uint32_t arg) { DECLARE_CRITICAL_SECTION(); uint8_t tmp; // dbg(DBG_SCHED, ("TOSH_post: %d 0x%x\n", TOSH_sched_free, (int)tp)); CRITICAL_SECTION_BEGIN(); tmp = TOSH_sched_free; if (TOSH_queue[tmp].tp == 0x0) { #ifdef TASK_QUEUE_DEBUG occupancy++; if (occupancy > max_occupancy) { max_occupancy = occupancy; } #endif if(pushqueue(¶mtaskQueue, arg)){ TOSH_sched_free = (tmp + 1) & sys_task_bitmask; TOSH_queue[tmp].tp = tp; TOSH_queue[tmp].postingFunction = (void *)__builtin_return_address(0); TOSH_queue[tmp].timestamp = OSCR0; TOSH_queue[tmp].executeTime = 0; } else{ printFatalErrorMsg("paramtaskqueue full",0); } CRITICAL_SECTION_END(); return 0x1; } else { #ifdef TASK_QUEUE_DEBUG failed_post++; #endif CRITICAL_SECTION_END(); printFatalErrorMsg("TaskQueue Full. Size = ", 1,sys_max_tasks); return 0x0; } }