dbc.c

来自「基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7」· C语言 代码 · 共 1,633 行 · 第 1/5 页

C
1,633
字号
        
    case MEMORY:
        
        DBC_Print_Line(" ***** Dynamic Memory Status Display *****\n\n\r");
        break;
    }
    
    /* Loop through all the the items that need to be displayed.  */
    while (total_items)
    {
    /* Loop through the number of items (or groups) that fit down on the
        screen.   */
        
        i =  0;
        
        while((i < items_per_height) && (total_items))
        {
        /* Walk through enough items to exhaust the columns and/or
            exhaust the number of items across.  */
            
            (*(DB_Item_Fields))();
            j = 0;
            while ((j < items_per_width) && (total_items))
            {
                
                
                (*(DB_Item_Information))(counter);
                counter++;
                
                /* Increment the j task variable.  */
                j++;
                
                /* Decrement the total number of items to print.  */
                total_items--;
            }
            
            /* Now we need to print the display lines.  */
            for (j = 0; j < total_fields; j++)
            {
                
                /* Print the line and position to the next line.  */
                DBC_Print_Line(Line_Pointers[j]);
                DBC_Print_Line(New_Line);
            }
            
            /* Position to another line and increment the counter for the
            number of items down.  */
            DBC_Print_Line(New_Line);
            i++;
        }
        
        /* If there are still more items to print, call pause to wait for
        the user to signal continuation.  */
        if (total_items)
            
            /* Pause before we continue on to the next page.  */
            DBC_Pause();
    }
}

/************************************************************************
*                                                                       
*   FUNCTION                                
*
*       DBC_Task_Fields                                                               
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       This routine prints out the task fields.                         
*                                                                       
*   INPUTS                                                                
*                                                                       
*       None                                                             
*                                                                       
*   OUTPUTS                                                               
*                                                                       
*       None                                                             
*                                                                       
************************************************************************/
VOID    DBC_Task_Fields()
{
    
    /* Initialize the various output lines.  */
    /*            sprintf(Line_Pointers[0],"Task Name:          ");
    sprintf(Line_Pointers[1],"Task Status:        ");
    sprintf(Line_Pointers[2],"Scheduled Count (H):");
    sprintf(Line_Pointers[3],"Priority:           ");
    sprintf(Line_Pointers[4],"Preemptable:        ");
    sprintf(Line_Pointers[5],"Time Slice:         ");
    sprintf(Line_Pointers[6],"Stack Base (H):     ");
    sprintf(Line_Pointers[7],"Stack Size:         "); 
    sprintf(Line_Pointers[8],"Minimum Stack:      "); */
    
    strcpy(Line_Pointers[0],"Task Name:          ");
    strcpy(Line_Pointers[1],"Task Status:        ");
    strcpy(Line_Pointers[2],"Scheduled Count (H):");
    strcpy(Line_Pointers[3],"Priority:           ");
    strcpy(Line_Pointers[4],"Preemptable:        ");
    strcpy(Line_Pointers[5],"Time Slice:         ");
    strcpy(Line_Pointers[6],"Stack Base (H):     ");
    strcpy(Line_Pointers[7],"Stack Size:         "); 
    strcpy(Line_Pointers[8],"Minimum Stack:      ");
}

/************************************************************************
*                                                                       
*   FUNCTION                                
*
*       DBC_Task_Information
*                                                                                                                                          
*   DESCRIPTION                                                           
*                                                                       
*       This routine prints out the task information.                    
*                                                                       
*   INPUTS                                                                
*                                                                       
*       counter     Current count                
*                                                                       
*   OUTPUTS                                                               
*                                                                       
*       None                                                             
*                                                                       
************************************************************************/
VOID    DBC_Task_Information(INT counter)
{
    OPTION          priority=0;                       /* Task Priority      */
    CHAR            name[9];                          /* Task Name          */
    DATA_ELEMENT    task_status;                      /* Current Task Status*/
    UNSIGNED        scheduled_count;                  /* Scheduled count    */
    OPTION          preempt=0;                        /* Task Preempt       */
    UNSIGNED        time_slice;                       /* Task Time/slice    */
    VOID            *stack_base;                      /* Task stack base    */
    UNSIGNED        stack_size;                       /* Task stack size    */
    UNSIGNED        minimum_stack;                    /* Minimum stack      */
    CHAR            temp[20];                         /* temp buffer for sprintf */    
    INT             n, i;
    
    /* Get information */
    NU_Task_Information(DBC_List[counter], name, &task_status,
        &scheduled_count, &priority,
        &preempt, &time_slice, &stack_base,
        &stack_size, &minimum_stack);
    /* NUL terminate name */
    name[8] = NUL;
    
    /* Build the Task's fields.  */
    /* sprintf(Output_Line,"%8s ", name); */
    n = strlen(name);
    if (n>=8)
    {
        strcpy(Output_Line, name);
        strcat(Output_Line, " ");
    }
    else
    {
        Output_Line[0] = 0;
        for (i=0;i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, name);
        strcat(Output_Line, " ");
    }
    
    DBT_String_Cat(Line_Pointers[0], Output_Line);
    
    /* Print a readable suspend status.  */
    switch (task_status)
    {
        
    case    NU_READY:
        
        /* Task is ready.  */
        DBT_String_Cat(Line_Pointers[1],"   READY ");
        break;
        
    case    NU_PURE_SUSPEND:
        
        /* Task is stopped.  */
        DBT_String_Cat(Line_Pointers[1]," STOPPED ");
        break;
        
    case    NU_FINISHED:
        
        /* Task is finished.  */
        DBT_String_Cat(Line_Pointers[1],"FINISHED ");
        break;
        
    case    NU_TERMINATED:
        
        /* Task is terminated.  */
        DBT_String_Cat(Line_Pointers[1],"  KILLED ");
        break;
        
    case    NU_SLEEP_SUSPEND:
        
        /* Task is waiting for a period of time.  */
        DBT_String_Cat(Line_Pointers[1],"   SLEEP ");
        break;
        
    case    NU_MAILBOX_SUSPEND:
        
        /* Task is waiting on a mailbox.  */
        DBT_String_Cat(Line_Pointers[1]," MAILBOX ");
        break;
        
    case    NU_QUEUE_SUSPEND:
        
        /* Task is waiting on a queue.  */
        DBT_String_Cat(Line_Pointers[1],"   QUEUE ");
        break;
        
    case    NU_PIPE_SUSPEND:
        
        /* Task is waiting on a pipe.  */
        DBT_String_Cat(Line_Pointers[1],"    PIPE ");
        break;
        
    case    NU_EVENT_SUSPEND:
        
        /* Task is waiting on events.  */
        DBT_String_Cat(Line_Pointers[1],"  EVENTS ");
        break;
        
    case    NU_SEMAPHORE_SUSPEND:
        
        /* Task is waiting on a resource.  */
        DBT_String_Cat(Line_Pointers[1],"    SEMA ");
        break;
        
    case    NU_MEMORY_SUSPEND:
        
        /* Task is waiting for memory.  */
        DBT_String_Cat(Line_Pointers[1],"  MEMORY ");
        break;
        
    case    NU_PARTITION_SUSPEND:
        
        /* Task is waiting for a partition.  */
        DBT_String_Cat(Line_Pointers[1],"PARTITION");
        break;
        
    case    NU_DRIVER_SUSPEND:
        
        /* Task is waiting for a driver.  */
        DBT_String_Cat(Line_Pointers[1],"  DRIVER ");
        break;
        
    default:
        
        /* sprintf(Output_Line,"%8s ", task_status); */
          Output_Line[0] = (CHAR)task_status;
          Output_Line[1] = 0;
          DBT_String_Cat(Line_Pointers[1], Output_Line);
        break;
    }
    
    /* sprintf(Output_Line,"%8X ", (UNSIGNED) scheduled_count); */
    NU_ITOA((INT)scheduled_count, temp, 16);
    n = strlen(temp);

    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    
    DBT_String_Cat(Line_Pointers[2], Output_Line);
    
    /* sprintf(Output_Line,"%8u ", (UNSIGNED) priority); */
    NU_ULTOA((UNSIGNED) priority, temp, 10);
    n = strlen(temp);
    
    if (n >= 8)
        strcpy(Output_Line, temp);
    else
    {
        Output_Line[0] = 0;
        for (i=0; i<(8-n);i++)
            strcat(Output_Line, " ");
        strcat(Output_Line, temp);
    }
    strcat(Output_Line, " ");
    
    DBT_String_Cat(Line_Pointers[3], Output_Line);
    
    /* Print a readable preempt status.  */
    switch (preempt)
    {
        
    case    10:
        
        /* Task is set for preempt.  */
        DBT_String_Cat(Line_Pointers[4],"     YES ");
        break;
        
    case    8:
        
        /* Task is set for no preempt.  */
        DBT_String_Cat(Line_Pointers[4],"      NO ");
        break;
        
    default:
        
        /* sprintf(Output_Line,"%8u ", (UNSIGNED) preempt); */
        NU_ULTOA((UNSIGNED) preempt, temp, 10);
        n = strlen(temp);
        
        if (n >= 8)
            strcpy(Output_Line, temp);
        else
        {
            Output_Line[0] = 0;
            for (i=0; i<(8-n);i++)
                strcat(Output_Line, " ");
            strcat(Output_Line, temp);
        }
        strcat(Output_Line, " ");
        
        DBT_String_Cat(Line_Pointers[4], Output_Line);
        break;
        
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?