changes made for resource measurement for 'enc' command. (#41)

Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/41
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
2026-07-30 19:57:31 +05:30
committed by neelimap
parent b08ac23f82
commit 8a999ce0ab
4 changed files with 440 additions and 13 deletions
+140 -13
View File
@@ -320,6 +320,33 @@ the VxWorks programmer guides.
#define STD_VALID(fd) (((fd) >= 0) && ((fd) < 3))
/* extern variable declaration */
/*
* uncomment the line below to measure open, close, read
* and write system calls for 'enc' command.
*/
/* #define MEASURE_SYS_CALLS */
#ifdef MEASURE_SYS_CALLS
extern int measurementFlag;
extern TASK_ID sysCallTaskID;
extern UINT32 tsFreq;
enum kernelAPI
{
openCall=0,
closeCall,
readCall,
writeCall,
sysCallMax,
};
typedef struct
{
unsigned int sysCallCount;
unsigned long int execTimeUsec;
}KRNL_API_STATS;
KRNL_API_STATS API_STATS[sysCallMax];
#endif
/* this tells core I/O if the system is configured for PSE52 */
extern BOOL iosPse52Mode;
@@ -591,7 +618,33 @@ int open
int mode /* mode of file to create (UNIX chmod style) */
)
{
return (ioCreateOrOpen (name, flags, mode, FALSE));
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[openCall].sysCallCount)++;
}
#endif
int result = ioCreateOrOpen(name, flags, mode, FALSE);
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[openCall].execTimeUsec)+=timeUs;
}
#endif
return result;
}
/*******************************************************************************
@@ -1008,20 +1061,43 @@ int close
(
int fd /* file descriptor to close */
)
{
int ret; /* the real close return value */
int krnPthreadCnclType; /* temp kernel canceltype saved value */
{
int ret; /* the real close return value */
int krnPthreadCnclType; /* temp kernel canceltype saved value */
if (_func_pthread_testandset_canceltype != NULL)
_func_pthread_testandset_canceltype (PTHREAD_CANCEL_ASYNCHRONOUS,
&krnPthreadCnclType);
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
ret = iosClose (fd);
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[closeCall].sysCallCount)++;
}
#endif
if (_func_pthread_testandset_canceltype != NULL)
_func_pthread_testandset_canceltype (krnPthreadCnclType, NULL);
if (_func_pthread_testandset_canceltype != NULL)
_func_pthread_testandset_canceltype (PTHREAD_CANCEL_ASYNCHRONOUS,
&krnPthreadCnclType);
return (ret);
ret = iosClose (fd);
if (_func_pthread_testandset_canceltype != NULL)
_func_pthread_testandset_canceltype (krnPthreadCnclType, NULL);
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[closeCall].execTimeUsec)+=timeUs;
}
#endif
return (ret);
}
/***************************************************************************
@@ -1099,7 +1175,33 @@ ssize_t read
return (0);
}
return (ioReadWrite (iosRead, fd, buffer, maxBytes));
ssize_t result;
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[readCall].sysCallCount)++;
}
#endif
result=(ioReadWrite (iosRead, fd, buffer, maxBytes));
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[readCall].execTimeUsec)+=timeUs;
}
#endif
return result;
}
@@ -1137,7 +1239,32 @@ ssize_t write
size_t nBytes /* number of bytes to write */
)
{
return (ioReadWrite (iosWrite, fd, buffer, nBytes));
ssize_t result;
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[writeCall].sysCallCount)++;
}
#endif
result=(ioReadWrite (iosWrite, fd, buffer, nBytes));
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[writeCall].execTimeUsec)+=timeUs;
}
#endif
return result;
}
/*******************************************************************************