/*! This function populates a given task structure with the parameters given. The stack is then initialized, and the task is set as stopped, and all state variables and timeouts reset. Once the task is created, it must be added using Task_Add(), and started using Tast_Start() \fn void Task_CreateTask( TASK_STRUCT *pstTask_, BYTE *pcName_, WORD* pwStack_, USHORT usStackSize_, UCHAR ucPriority_, TASK_FUNC pfFunction_) \sa Task_Add(), Task_Start() \brief Add a task from the scheduler list \sa Task_Remove() \param pstTask_ - pointer to the task structure to build \param pcName_ - pointer to the task name \param pwStack_ - pointer to the task's stack \param usStackSize_ - the length of the stack in bytes \param ucPriority_ - priority of the task (0-255) \param pfFunction_ - pointer to the task's entry function \return (BOOL) TRUE on success, FAIL on failure */ void Task_CreateTask( TASK_STRUCT *pstTask_, BYTE *pcName_, WORD* pwStack_, USHORT usStackSize_, UCHAR ucPriority_, TASK_FUNC pfFunction_) { // Assign the task name pstTask_->pacName = pcName_; // Stack size pstTask_->usStackSize = usStackSize_; // Assign the task priority pstTask_->ucPriority = ucPriority_; // Set the task to the "stopped" state pstTask_->eState = TASK_STOPPED; // Set the stack pointer to the top of the task -> grow down/up depending on architecture. pstTask_->pwTopStack = (WORD*)TOP_OF_STACK(pwStack_, usStackSize_); pstTask_->pwStack = pwStack_; // Set the task entry function to the one provided pstTask_->pfTaskFunc = pfFunction_; // Wait time to 0 on init. pstTask_->usTimeLeft = 0; // Set the quantum to 1 tick #if KERNEL_USE_QUANTUM pstTask_->usQuantum = 1; #endif // KERNEL_USE_QUANTUM #if KERNEL_USE_SEMAPHORE pstTask_->pstNextList = NULL; #endif // KERNEL_USE_SEMAPHORE #if KERNEL_USE_MUTEX pstTask_->pstNextList = NULL; pstTask_->ucMutexPriority = 0; #endif // KERNEL_USE_MUTEX // Initialize the stack... Task_InitStack(pstTask_); }
void push_nav(QSP_ARG_DECL Gen_Win *gwp) { Gen_Win *current_gwp; // We can push a viewer or anything!? //assert( GW_TYPE(NAVP_GW(np_p)) == GW_NAV_PANEL ); if( nav_stack == NULL ) nav_stack = new_stack(); // We need to keep a stack of panels... if( (current_gwp=TOP_OF_STACK(nav_stack)) != NULL ){ unshow_genwin(QSP_ARG current_gwp); } PUSH_TO_STACK(nav_stack,gwp); //fprintf(stderr,"showing associated panel %s\n",PO_NAME(NAVP_PANEL(gwp))); show_genwin(QSP_ARG gwp); }
void pop_nav(QSP_ARG_DECL int count) { Gen_Win *gwp; if( nav_stack == NULL ) nav_stack = new_stack(); gwp = POP_FROM_STACK(nav_stack); assert( gwp != NULL ); unshow_genwin(QSP_ARG gwp); count --; while( count -- ){ gwp = POP_FROM_STACK(nav_stack); assert( gwp != NULL ); } assert( (gwp=TOP_OF_STACK(nav_stack)) != NULL ); show_genwin(QSP_ARG gwp); }