⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-wtx5.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
*/  int main      (     int             argc, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* number of arguments */     char *  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argv[] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* table of arguments */     )     {     UINT32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ix = 0; &nbsp;&nbsp;&nbsp;&nbsp;/* useful counter */     UINT32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blockSize;  /* size of a memory block */     WTX_MEM_INFO * &nbsp;pMemInfo;   /* target memory pool info */      /* check input arguments */      if (argc != 2)          {         printf ("Usage: wtxapp targetServerName\n");         exit(0);         }           /*      * Initialize signal handlers. This is necessary to avoid a tool     * killed via Control-C or another signal remaining attached to a      * target server.     */      if (wtxAppSigInit() != OK)         {         printf ("Error: cannot initialize signal handler\n");         exit (0);         }      /* initialize WTX session */      if (wtxInitialize (&amp;wtxh) != OK)         {         printf ("Error: cannot initialize WTX API\n");         exit (0);         }      /* attach to target server */      if (wtxToolAttach (wtxh, argv[1], "wtxapp") != OK)         {         printf ("Error: cannot attach to target server: %s\n", argv[1]);         wtxTerminate (wtxh);         exit (0);         }      printf ("Attaching to target server done\n");      /* register for events we want to hear about */      if (wtxRegisterForEvent (wtxh, ".*") != OK)         {         printf ("Error: cannot register for events\n");         wtxAppTerminate ();         }      /* get memory pool information */      if ((pMemInfo = wtxMemInfoGet (wtxh)) == NULL)         {         printf ("Error: cannot get target memory information\n");         wtxAppTerminate ();         }      printf ("Starting target memory allocate/free demonstration\n");     printf ("Type Control-C to stop\n");      /* allocate approx. 1/NUM_BLOCKS of the biggest available blocks */      blockSize = pMemInfo-&gt;biggestBlockSize / NUM_BLOCKS - 200;      for (;;)         {         /* allocate blocks */          for (ix = 0; ix &lt; NUM_BLOCKS; ix++)             {             printf ("Allocating block #%02d\r", ix+1);             blockTab [ix] = wtxMemAlloc (wtxh, blockSize);              if (blockTab[ix] == (TGT_ADDR_T) 0)                 {                 printf ("Error: cannot allocate target memory\n");                 wtxAppTerminate ();                 }              #ifdef WIN32                 Sleep (1000);       /* wait 1 second */             #else                 sleep (1);          /* wait 1 second */             #endif                 fflush (stdout);             }          /* free blocks */          for (ix = 0; ix &lt; NUM_BLOCKS; ix++)             {             printf ("Freeing block #%02d   \r", ix+1);              if (wtxMemFree (wtxh, blockTab [ix]) != OK)                 {                 printf ("Error: cannot free target memory\n");                 wtxAppTerminate ();                 }             blockTab [ix] = (TGT_ADDR_T) 0;                  #ifdef WIN32                 Sleep (1000);       /* wait 1 second */             #else                 sleep (1);          /* wait 1 second */             #endif             fflush (stdout);             }         }     return 0;     }  /******************************************************************* * * wtxAppSigInit - initialize signal handlers * * wtxAppSigInit() installs the signal handlers needed by wtxapp. * * RETURNS: N/A */  STATUS wtxAppSigInit (void)     {     #ifndef WIN32         int                 ix;         struct sigaction    sv;         struct sigaction    bb;          /* setup default signal handler */          sv.sa_handler = (VOIDFUNCPTR) wtxAppSigHandler;         sigemptyset (&amp;sv.sa_mask);         sv.sa_flags   = 0;          for (ix = SIGHUP; ix &lt; SIGALRM; ix++)   /* capture errors */             sigaction (ix, &amp;sv, &amp;bb);          sigaction (SIGTERM, &amp;sv, &amp;bb);          /* terminate */     #else         SetConsoleCtrlHandler(wtxAppSigHandler, TRUE);  /* trap signals */     #endif     return OK;     }  /********************************************************************* * * wtxAppTerminate - terminate wtxapp properly * * This routine performs all necessary cleanup required when an attached tool * finishes a WTX session with a target server.  * * RETURNS: N/A */  LOCAL void wtxAppTerminate (void)     {     int ix;      printf ("\nFreeing all the memory blocks\n");     for (ix = 0; ix &lt; NUM_BLOCKS; ix++)         {         if (blockTab [ix] != (TGT_ADDR_T) 0)             {             wtxMemFree (wtxh, blockTab [ix]);             }         }     wtxToolDetach (wtxh);           /* detach from target server */     wtxTerminate (wtxh);            /* terminate WTX session */      exit (0);                               /* bye */     }  /******************************************************************* * * wtxAppSigHandler - wtxapp signal handler * * This function is the signal handler for wtxapp.  It calls * wtxAppTerminate() to perform the WTX session closing. * * RETURNS: N/A */  #ifdef WIN32     BOOL WINAPI wtxAppSigHandler      (     DWORD                   dwCtrlType     ) #else     LOCAL void wtxAppSigHandler      (     int                             signal,     int                             code     ) #endif      {     wtxAppTerminate (); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* terminate session cleanly */      #ifdef WIN32     return 0;     #endif     }</a></b></pre></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-wtx.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-wtx.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-wtx4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-wtx6.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

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