linuxÏÂͳ¼ÆÊ±¼äÀà
class CTimeTickCount
{
public:
CTimeTickCount(int threadIndex, int id )
{
struct timezone tz;
gettimeofday(&m_tvStartTime, &tz);
// m_tmStartTime = ACE_OS::gettimeofday();
m_iThreadIndex = threadIndex;
m_iID = id;
}
~CTimeTickCount()
{
struct timezone tz;
struct timeval tv;
gettimeofday(&tv, &tz);
// ACE_Time_Value currTime = ACE_OS::gettimeofday();
long cost = (tv.tv_sec - m_tvStartTime.tv_sec) * 1000 * 1000;
cost += (tv.tv_usec - m_tvStartTime.tv_usec );
if(cost >= 100 * 1000 )
{
//NVS_DEBUG((NVS_LM_ERROR, "====thread no: %d, cost time: %dms, id: %d.",
// m_iThreadIndex, cost, m_iID));
printf( "====thread no: %d, cost time: %dms, id: %d.\n", m_iThreadIndex, cost, m_iID));
}
}
private:
struct timeval m_tvStartTime; // ACE_Time_Value m_tmStartTime; // ¿ªÊ¼Ê±¼ä
int m_iThreadIndex; // Ï̺߳Å
int m_iID; // ±êʾ
};
Ïà¹ØÎĵµ£º
ÐéÄâ»úlinux°æ±¾£ºredhat9.0
×ܽáһϣºÒª±£Ö¤ÐéÄâ»úϵͳ¿ÉÒÔÉÏÍø£¬µÃÏȽâ¾öÐéÄâ»úºÍÕæÊµÖ÷»úµÄÁ¬½Ó¹ØÏµ¡£VMwareÖ÷Òª¸ø³ö3ÖÖģʽ£¬ÎÒÃdz£ÓõÄÓГbridge£¨ÇŽӣ©”ºÍ
“Nat£¨ÍøÂçµØÖ·×ª»»£©”·½Ê½¡£ÐéÄâ»úÉèÖ÷½·¨£ºµ¥»÷“ÐéÄâ»ú”→“ÉèÖÔ→“ÒÔÌ«Íø£¬È»ºóÑ¡ÔñÁ ......
ÎÄÕÂѡȡµÄÀý×ӷdz£¼òµ¥£¬ÉÏÊÖÈÝÒ×£¬Ö»ÊÇΪÁ˽²Êö¾²Ì¬Ó붯̬Á´½Ó¿âµÄÉú³ÉºÍÁ´½Ó¹ý
³Ì£¬»¹ÓÐËûÃÇÖ®¼äµÄÇø±ð¡£ÒÔÏÂÀý×ÓÔÚ gcc 4.1.1 ÏÂ˳Àûͨ¹ý¡£
ÎļþÔ¤ÀÀ
ÎļþĿ¼Ê÷ÈçÏ£¬ÈçÄãËù¼û£¬·Ç³£¼òµ¥¡£
libtest/
|-- lt.c
|-- lt.h
`-- test. ......
ÓɲÙ×÷ϵͳʵÏÖµÄËùÓÐϵͳµ÷ÓÃËù¹¹³ÉµÄ¼¯ºÏ¼´³ÌÐò½Ó¿Ú»òÓ¦Óñà³Ì½Ó¿Ú(Application Programming Interface£¬API)¡£ÊÇÓ¦ÓóÌÐòͬϵͳ֮¼äµÄ½Ó¿Ú¡£
¡¡¡¡²Ù×÷ϵͳµÄÖ÷Òª¹¦ÄÜÊÇΪӦÓóÌÐòµÄÔËÐд´½¨Á¼ºÃµÄ»·¾³£¬ÎªÁË´ïµ½Õâ¸öÄ¿µÄ£¬ÄÚºËÌṩһϵÁо߱¸Ô¤¶¨¹¦ÄܵĵÄÄں˺¯Êý£¬Í¨¹ýÒ»×é³ÆÎªÏµÍ³µ÷Óõģ¨system call)µÄ½Ó¿Ú³ÊÏÖ¸øÓà ......
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
int main()
{
printf("sizeof(off_t) = %d\n", sizeof(off_t));
int ......