亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bufftest.c

?? TI的例程
?? C
字號:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DSP/BIOS 4.90.270 01-13-05 (barracuda-o07)" */
/***************************************************************************/
/*                                                                         */
/*     B U F F T E S T . C                                                 */
/*                                                                         */
/*   Simulating a network environment where the server program gathers     */
/*   statistics about various requests from clients in real-time.          */
/*   CLK Object simulates hardware interrupts from clients. CLK Isr        */
/*   allocates buffers from a Buffer Pool created statically in CDB and    */
/*   make them available in a queue for processing task. A periodic object */
/*   prints the statistics about the Buffer Pool usage and type of         */
/*   requests from clients.                                                */
/*                                                                         */
/***************************************************************************/
 
 
#include <std.h>
#include <log.h>
#include <swi.h>
#include <clk.h>
#include <que.h>
#include <sys.h>
#include <buf.h>

#include "bufftestcfg.h"

#define TOTAL_SERVICES 4  /* Total number of various request types from clinets */

#define MAX_BUFFERS    5  /* Total number of buffers in the Buffer Pool */


/* define client request types (these services can be extended) */
typedef enum ServiceType {
     GET_SYSTEM_TIME_HIGH = 0,
     GET_SYSTEM_TIME_LOW,
     GET_CPU_LOAD,
     RUN_USER_FXN
}ServiceType;

/* 
 * define a structure for buffer header which contains information
 * about the type of request from clients
 */

typedef struct BufferHeader {
     QUE_Elem  elem; /*  elem will be used by QUE module */
     ServiceType service;    /*  client request type  */    
     Fxn userFxn;    /*  user function to be executed */
}BufferHeader;

extern BUF_Obj bufferPool;
extern QUE_Obj bufferQueue;
extern SWI_Obj buffSwi;
extern LOG_Obj trace;
extern Int SEG0;

BUF_Handle  buffPoolHandle = &bufferPool; 

QUE_Handle  bufferQueueHandle = &bufferQueue;

/* numberOfBuffers holds number of Buffers allocated by SWI */
Int numberOfBuffers; 

/* define an array for collecting statistics about various request types  */
Int requestStatistics[TOTAL_SERVICES];



/* service functions */

Void serviceClientRequest(Ptr buffPtr);
Void getSystemTimeHigh();
Void getSystemTimeLow();
Void getMemoryStatus(Int segid);
Void getCpuLoad();
Int  defaultUserFunction();
 
/*
 * ======== main ========
 */
Void main()
{
    LOG_printf(&trace,"Bufftest example started.\n");
}

/*
 *  ======== processingTskFxn ========
 *
 * FUNCTION: Called from DSP/BIOS startup to process the client requests
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void processingTskFxn()
{
   Ptr buffPtr;
  
    for (;;) {

       if (QUE_empty(bufferQueueHandle)) {
       
           TSK_sleep(1);
           
       } else {
       
           while (!QUE_empty(bufferQueueHandle)) {
           
              /* get a request(i.e. buffer filled with request info) from buffer queue  */   
              buffPtr = QUE_get(bufferQueueHandle);
              
              /* update the statistics */
              serviceClientRequest(buffPtr);   
              
              /* free the buffer after servicing the request*/
              BUF_free(buffPoolHandle, buffPtr); 
              
           }
           
       }
       
    }        
}

/*
 *  ======== serviceClientRequest ========
 *
 * FUNCTION: Called from processingTskFxn function to service the client request
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
 
Void serviceClientRequest(Ptr buffPtr)
{
   BufferHeader *header;
   ServiceType service;

     header = (BufferHeader *) buffPtr;
     
     service  =  header->service;
     
     /* update the statisics for each occurence of the request */
     requestStatistics[service]++ ; 
     
     /* service the request */
     switch (service) {
     
          case  GET_SYSTEM_TIME_HIGH : 
                  getSystemTimeHigh();
                  break;
                          
          case  GET_SYSTEM_TIME_LOW : 
                  getSystemTimeLow();
                  break;
                  
          case  GET_CPU_LOAD :
                  getCpuLoad();
                  break;                 
          
          case  RUN_USER_FXN :
                ( *(header->userFxn) )() ;
                
     }
     
}

/*
 *  ======== clkIsr ========
 *
 * FUNCTION: Called by CLK module for each timer interrupt. It generates the 
 *           number of buffers to be allocated and pass it to buffSwi
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void clkIsr()
{
   BUF_Stat stat;
   Int randomBuffers;
   
     /*  Get the random number of buffers required */
      randomBuffers = getRandomNum(MAX_BUFFERS) + 1;
   
      /* Read the Buffer Pool statistics to get number of freebuffers */ 
      BUF_stat(buffPoolHandle, &stat);
      
      if ( randomBuffers > stat.freebuffers ){
            randomBuffers = stat.freebuffers;
      }
   
      numberOfBuffers = randomBuffers;
   
      /* post a SWI to allocate buffers (numberOfBuffers)*/
      SWI_post(&buffSwi);
}


/*
 *  ======== buffAllocate ========
 *
 * FUNCTION: Called from buffSwi to allocate buffers and fill them with client request info
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void buffAllocate(Arg numberOfBuffers)
{

  BufferHeader * header;
  Ptr buffPtr;
  Int numbuff, i;
    
    numbuff = *(Int *) numberOfBuffers;
    
    for (i = 0; i < numbuff; i++) {       
          
          /* allocating a buffer in  SWI context*/
          buffPtr = BUF_alloc(buffPoolHandle); 
          if (buffPtr == NULL ) {
              SYS_abort("BUF_alloc failed");
          }
       
           /*  fill the buffer with info about request type */
           header = (BufferHeader *) buffPtr;
           header->service = (ServiceType) getRandomNum(TOTAL_SERVICES);
           
           if (header->service == RUN_USER_FXN ) {
               /* this is a dummy function used here and can be replaced */
               header->userFxn = defaultUserFunction; 
           }
                    
          /*  
           * make the buffer available to the processing task 
           * by putting the buffer in the buffer queue
           */
          QUE_put(bufferQueueHandle, buffPtr); 
    }
    
}


/*
 *  ======== printStatistics ========
 *
 * FUNCTION: Called from statisticsPrd to print statistics about client requests
 *           and Buffer Pool usage for every 16 ticks
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void printStatistics()
{

  BUF_Stat stat;
  Int  maxbuff;
  Int service;
  Int totalRequests = 0;

    BUF_stat(buffPoolHandle, &stat);
 
    maxbuff = BUF_maxbuff(buffPoolHandle);
    
    LOG_printf(&trace, "After 16 ticks, Free buffers Available : %d, Max buffers used : %d ", stat.freebuffers, maxbuff);
    
    for (service = 0; service < TOTAL_SERVICES; service++ ) {
    
       /* print statistics for each request */
       switch (service) {
     
          case  GET_SYSTEM_TIME_HIGH : 
              LOG_printf(&trace, "Number of GET_SYSTEM_TIME_HIGH requests : %d", requestStatistics[service]);
              break;
                          
          case  GET_SYSTEM_TIME_LOW : 
              LOG_printf(&trace, "Number of GET_SYSTEM_TIME_LOW requests : %d", requestStatistics[service]);
              break;
                  
          case  GET_CPU_LOAD : 
              LOG_printf(&trace, "Number of GET_CPU_LOAD requests : %d", requestStatistics[service]);
              break;                 
          
          case  RUN_USER_FXN :
              LOG_printf(&trace, "Number of RUN_USER_FXN requests : %d", requestStatistics[service]);
     }
     
     totalRequests += requestStatistics[service];
       
       /*  Reset the count for the next statistics */
     requestStatistics[service] = 0; 
   }
    
    LOG_printf(&trace, "Total number of requests in 16 ticks : %d \n", totalRequests );
     
}

/*
 *  ======== getRandomNum ========
 *
 * FUNCTION: Called from clkIsr and buffAllocate generate a random number
 *           It returns a integer between 0 to maxValue-1 inclusive
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Int  getRandomNum(Int maxValue)
{ 
   LgInt randomNumber;

   randomNumber  =  CLK_gethtime() % maxValue;
   
   if (randomNumber < 0) {
      randomNumber *= -1;
   }
   
   return  randomNumber ;
}


/*
 *  ======== getSystemTimeHigh ========
 *
 * FUNCTION: Called from serviceClientRequest to service GET_SYSTEM_TIME_HIGH request
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void getSystemTimeHigh()
{
     LgUns  currtime;

     currtime = CLK_gethtime();
     
     #ifdef _28_
        LOG_printf(&trace, "High Resolution System Time : 0x%04x%04x\n", (Arg)(currtime >> 16), (Arg)(currtime & 0xffff));
     #else
        LOG_printf(&trace, "High Resolution System Time : 0x%04x%04x\n", (Int)(currtime >> 16), (Int)(currtime & 0xffff));
     #endif
     
}

/*
 *  ======== getSystemTimeLow ========
 *
 * FUNCTION: Called from serviceClientRequest to service GET_SYSTEM_TIME_LOW request
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void getSystemTimeLow()
{
     LgUns  currtime;

     currtime = CLK_getltime();
     
     #ifdef _28_
        LOG_printf(&trace, "Low Resolution System Time : 0x%04x%04x\n", (Arg)(currtime >> 16), (Arg)(currtime & 0xffff));
     #else
        LOG_printf(&trace, "Low Resolution System Time : 0x%04x%04x\n", (Int)(currtime >> 16), (Int)(currtime & 0xffff));
     #endif
     
}

 
/*
 *  ======== getCpuLoad ========
 *
 * FUNCTION: Called from serviceClientRequest to service GET_CPU_LOAD request
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: none.
 */
Void getCpuLoad()
{

    LgInt max, num, acc;    /* max, num, acc fields of STS Object */
    Int cpuload;
    
     /*
      * Read BIOS defined STS object IDL_busyObj to get the following
      * num : number of times the DSP/BIOS idle loop is run in 1 second.
      * max : minimum number of CPU cycles taken for one idle loop execution.
      * acc : total number of CPU cycles elapsed in 1 second.
      *
      * cpu load =  app_cycles / total_cycles 
      *          =  (total_cycles - idleloop_cycles) / total_cycles
      *          =  1 -  (idleloop_cycles / total_cycles)
      * idleloop_cycles =  num * max / acc
      */ 
    
#if defined(_54_) /* Handle specific implementation for 54x */
    Int maxh, maxl, numh, numl, acch, accl;
    
    maxh = IDL_busyObj.maxh;
    maxl = IDL_busyObj.maxl;
    numh = IDL_busyObj.numh;
    numl = IDL_busyObj.numl;
    acch = IDL_busyObj.acch;
    accl = IDL_busyObj.accl;
   
    max = maxh;
    max = (max << 16) | (0x0000ffff & maxl);
    num = numh;
    num = (num << 16) | (0x0000ffff & numl);    
    acc = acch;
    acc = (acc << 16) | (0x0000ffff & accl);
#else
    max = IDL_busyObj.max;    
    num = IDL_busyObj.num;   
    acc = IDL_busyObj.acc;           
#endif
    
    /* Calculate approximate cpu load */
    
    cpuload = ( num * max * 1.0 / acc ) * 100; /* gives idleload%  */
    
    if (cpuload < 0) {  /* since STS maintains -ve numbers for max/acc field */
         cpuload *= -1;
    }     
    
    cpuload = 100 - cpuload ; /* cpuload% =  100 - idleload% */
    
 #ifndef _28_ /* due to 28x BIOS issue, num, acc and max fields are invalid */ 
    LOG_printf(&trace, "cpu load is : %d%%\n", cpuload);
 #endif
}

/*
 *  ======== defaultUserFunction ========
 *
 * FUNCTION: Called from serviceClientRequest to service RUN_USER_FXN request
 *
 * PARAMETERS: none
 *
 * RETURN VALUE: Int ( dummy return since Fxn type returns integer).
 */
Int defaultUserFunction()
{
  LOG_printf(&trace, "User Function called\n"); 
  return 1;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天综合网天天狠天天| 欧美xfplay| 91精品国产一区二区| 中文字幕高清一区| 日韩不卡一区二区| 色综合久久久久综合体| 精品国产免费一区二区三区香蕉| 一区二区三区在线播| 国产一区二区三区美女| 欧美日韩国产中文| 亚洲乱码精品一二三四区日韩在线| 精品在线观看视频| 欧美精品在欧美一区二区少妇| 日韩毛片精品高清免费| 国产精品资源在线看| 日韩欧美另类在线| 日韩在线一区二区三区| 在线观看国产精品网站| 亚洲三级在线观看| av爱爱亚洲一区| 中文字幕免费不卡| 国产一区二区视频在线| 精品国产区一区| 狠狠色狠狠色综合系列| 精品国产123| 国内精品国产三级国产a久久| 日韩欧美专区在线| 久久精品国产99久久6| 日韩三级免费观看| 久久福利视频一区二区| 欧美电视剧在线看免费| 蜜桃91丨九色丨蝌蚪91桃色| 日韩午夜电影在线观看| 免费观看91视频大全| 欧美成人猛片aaaaaaa| 久久99精品久久久久久久久久久久| 91精品免费在线观看| 免费一级片91| 国产亚洲精品免费| 99精品在线观看视频| 一区二区成人在线观看| 欧美色区777第一页| 亚洲国产精品久久不卡毛片| 欧美人与z0zoxxxx视频| 日韩精品欧美精品| 精品国产乱码久久久久久免费| 国产永久精品大片wwwapp| 国产日韩三级在线| 91日韩在线专区| 亚洲在线中文字幕| 日韩欧美国产一区二区三区| 国产激情视频一区二区三区欧美| 欧美国产一区在线| 精品视频在线免费看| 日本中文在线一区| 国产拍揄自揄精品视频麻豆| 97精品久久久午夜一区二区三区| 亚洲国产色一区| 日韩免费高清电影| 99精品国产视频| 天天影视涩香欲综合网| 久久伊人中文字幕| 色婷婷综合五月| 免费高清成人在线| 中文字幕日韩一区| 日韩一卡二卡三卡国产欧美| 成人夜色视频网站在线观看| 亚洲第一久久影院| 国产欧美一区二区三区在线看蜜臀| 色婷婷综合激情| 国内精品伊人久久久久av一坑| 亚洲欧美偷拍三级| 欧美mv和日韩mv国产网站| 91丨国产丨九色丨pron| 奇米影视一区二区三区小说| 亚洲欧美乱综合| 2欧美一区二区三区在线观看视频| 97久久久精品综合88久久| 久久国产免费看| 亚洲风情在线资源站| 中文字幕乱码亚洲精品一区| 欧美一区二区三区四区视频| www.激情成人| 激情综合五月天| 午夜视频在线观看一区二区| 国产精品美女久久久久久久| 日韩一区二区精品在线观看| 在线一区二区观看| 成人美女在线视频| 狠狠狠色丁香婷婷综合激情| 水野朝阳av一区二区三区| 自拍偷自拍亚洲精品播放| 精品第一国产综合精品aⅴ| 欧美日韩一区小说| 色香色香欲天天天影视综合网| 国产福利一区二区| 精品一区二区在线免费观看| 亚洲成人免费在线观看| 亚洲人一二三区| 国产精品电影院| 久久精品夜色噜噜亚洲a∨| 欧美一级二级在线观看| 欧美日韩精品综合在线| 欧洲视频一区二区| 色悠悠亚洲一区二区| 成人ar影院免费观看视频| 国产精品 欧美精品| 精品一区二区三区不卡| 日韩不卡免费视频| 日产国产欧美视频一区精品| 亚洲图片欧美一区| 亚洲a一区二区| 午夜av一区二区| 日韩—二三区免费观看av| 亚洲v中文字幕| 日韩精品免费视频人成| 午夜激情一区二区三区| 日韩中文字幕亚洲一区二区va在线| 天天综合天天综合色| 青娱乐精品视频| 男人的天堂久久精品| 久久综合综合久久综合| 久久精品久久99精品久久| 国内精品免费**视频| 国产不卡一区视频| av电影天堂一区二区在线观看| 91丝袜美腿高跟国产极品老师 | 99久久99久久综合| 99久久久精品| 欧洲一区在线观看| 欧美一三区三区四区免费在线看| 日韩欧美国产高清| 欧美大片日本大片免费观看| 日韩欧美激情一区| 国产日韩在线不卡| 亚洲主播在线观看| 九九视频精品免费| 99这里都是精品| 欧美日韩美少妇| 久久久久久久久蜜桃| 国产精品高清亚洲| 亚洲1区2区3区视频| 精品系列免费在线观看| 成人av在线电影| 欧美老肥妇做.爰bbww视频| 精品久久一区二区三区| 1000精品久久久久久久久| 亚洲风情在线资源站| 国产一区二区免费在线| 色琪琪一区二区三区亚洲区| 欧美一区二区三区在线电影| 中文子幕无线码一区tr| 香蕉成人伊视频在线观看| 国产一区二区三区蝌蚪| 色婷婷av一区| 国产网站一区二区| 午夜精品视频在线观看| 国产风韵犹存在线视精品| 欧美性极品少妇| 国产精品久久夜| 久久福利资源站| 欧美丝袜丝交足nylons| 日本一区二区视频在线| 日韩精品福利网| 色综合色综合色综合| 26uuu欧美| 日韩高清一级片| 色哟哟一区二区| 中文字幕久久午夜不卡| 理论片日本一区| 欧美午夜精品一区二区蜜桃| 中文字幕不卡在线播放| 日本在线不卡一区| 欧美中文字幕一区二区三区 | 亚洲第一在线综合网站| 成人午夜电影久久影院| 欧美成人性战久久| 视频一区二区三区入口| 在线观看免费视频综合| 亚洲视频在线观看一区| 韩国精品久久久| 日韩视频在线永久播放| 午夜精品福利在线| 欧洲精品视频在线观看| 亚洲欧美日韩一区二区| 成人av在线电影| 日本一区二区三区免费乱视频| 激情综合网av| 精品1区2区在线观看| 久久精品二区亚洲w码| 欧美精品一级二级三级| 亚洲午夜久久久| 欧美日韩在线电影| 亚洲一区二区高清| 欧美日韩国产不卡| 亚洲成人av一区| 欧美日韩在线播放三区| 午夜av一区二区三区| 91精品综合久久久久久| 亚洲韩国精品一区|