make getsysinfo() a system-land call
This commit is contained in:
@@ -5,6 +5,7 @@ LIB= sys
|
||||
SRCS= \
|
||||
alloc_util.c \
|
||||
assert.c \
|
||||
getsysinfo.c \
|
||||
kernel_call.c \
|
||||
panic.c \
|
||||
pci_attr_r16.c \
|
||||
|
||||
+9
-13
@@ -6,21 +6,19 @@
|
||||
* getidle();
|
||||
* ...
|
||||
* idleperc = getidle();
|
||||
* printf("CPU usage: %lg%%\n", 100.0 - idleperc);
|
||||
* if (idleperc >= 0.0)
|
||||
* printf("CPU usage: %lg%%\n", 100.0 - idleperc);
|
||||
*
|
||||
* This routine goes through PM to get the idle time, rather than making the
|
||||
* sys_getinfo() call to the kernel directly. This means that it can be used
|
||||
* by non-system processes as well, but it will incur some extra overhead in
|
||||
* the system case. The overhead does not end up being measured, because the
|
||||
* system is clearly not idle while the system calls are being made. In any
|
||||
* case, for this reason, only one getidle() run is allowed at a time.
|
||||
* Notes:
|
||||
* - This functionality can only be used by system processes.
|
||||
* - The kernel has to be compiled with CONFIG_IDLE_TSC support.
|
||||
* - Only one getidle() run is allowed per process at a time.
|
||||
*
|
||||
* Note that the kernel has to be compiled with CONFIG_IDLE_TSC support.
|
||||
*/
|
||||
|
||||
#define _MINIX 1
|
||||
#define _SYSTEM 1
|
||||
#include <minix/sysinfo.h>
|
||||
#include <lib.h>
|
||||
#include <minix/u64.h>
|
||||
#include <minix/sysutil.h>
|
||||
|
||||
@@ -52,8 +50,7 @@ double getidle(void)
|
||||
int r;
|
||||
|
||||
if (!running) {
|
||||
r = getsysinfo_up(PM_PROC_NR, SIU_IDLETSC, sizeof(idle), &idle);
|
||||
if (r != sizeof(idle))
|
||||
if ((r = sys_getidletsc(&idle)) != OK)
|
||||
return -1.0;
|
||||
|
||||
running = 1;
|
||||
@@ -67,8 +64,7 @@ double getidle(void)
|
||||
|
||||
running = 0;
|
||||
|
||||
r = getsysinfo_up(PM_PROC_NR, SIU_IDLETSC, sizeof(idle2), &idle2);
|
||||
if (r != sizeof(idle2))
|
||||
if ((r = sys_getidletsc(&idle2)) != OK)
|
||||
return -1.0;
|
||||
|
||||
idelta = sub64(idle2, idle);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#include <lib.h>
|
||||
#include <minix/sysinfo.h>
|
||||
#include <minix/com.h>
|
||||
|
||||
PUBLIC int getsysinfo(who, what, where)
|
||||
endpoint_t who; /* from whom to request info */
|
||||
int what; /* what information is requested */
|
||||
void *where; /* where to put it */
|
||||
{
|
||||
message m;
|
||||
m.SI_WHAT = what;
|
||||
m.SI_WHERE = where;
|
||||
if (_syscall(who, COMMON_GETSYSINFO, &m) < 0) return(-1);
|
||||
return(0);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ pci_dev_name.c
|
||||
*===========================================================================*/
|
||||
PUBLIC char *pci_dev_name(u16_t vid, u16_t did)
|
||||
{
|
||||
static char name[PCIINFO_ENTRY_SIZE]; /* We need a better interface for this */
|
||||
static char name[80]; /* We need a better interface for this */
|
||||
|
||||
int r;
|
||||
cp_grant_id_t gid;
|
||||
|
||||
Reference in New Issue
Block a user