Changeset 1924 for trunk/src/kernel32/oslibdos.cpp
- Timestamp:
- Dec 1, 1999, 7:40:49 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/oslibdos.cpp
r1914 r1924 1 /* $Id: oslibdos.cpp,v 1.1 1 1999-12-01 10:47:51sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.12 1999-12-01 18:40:48 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include "initterm.h" 24 24 #include "oslibdos.h" 25 #include "dosqss.h" 25 26 26 27 APIRET APIENTRY DosAliasMem(PVOID pb, ULONG cb, PPVOID ppbAlias, ULONG fl); … … 548 549 } 549 550 //****************************************************************************** 550 //****************************************************************************** 551 //Returns time spent in kernel & user mode in milliseconds 552 //****************************************************************************** 553 BOOL OSLibDosQueryProcTimes(DWORD procid, ULONG *kerneltime, ULONG *usertime) 554 { 555 APIRET rc; 556 char *buf; 557 ULONG size; 558 ULONG nrthreads = 4; 559 560 tryagain: 561 size = sizeof(QTOPLEVEL)+sizeof(QGLOBAL)+sizeof(QPROCESS) + nrthreads*sizeof(QTHREAD); 562 buf = (char *)malloc(size); 563 rc = DosQuerySysState(0x1, RESERVED, procid, RESERVED, (PCHAR)buf, size); 564 565 if(rc) { 566 free(buf); 567 if(rc == ERROR_BUFFER_OVERFLOW) { 568 nrthreads += 4; 569 goto tryagain; 570 } 571 return FALSE; 572 } 573 PQTOPLEVEL top = (PQTOPLEVEL)buf; 574 575 *kerneltime = 0; 576 *usertime = 0; 577 for(int i=0;i<top->procdata->threadcnt;i++) { 578 *kerneltime += top->procdata->threads[i].systime; 579 *usertime += top->procdata->threads[i].usertime; 580 } 581 free(buf); 582 return TRUE; 583 } 584 //****************************************************************************** 585 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.