📄 mosctl.c
字号:
/* * Copyright (c) 2000, Amnon BARAK (amnon@cs.huji.ac.il). All rights reserved. * * OpenMosix $Id: mosctl.c,v 1.11 2003/05/14 22:27:14 demichel Exp $ * * Permission to use, copy and distribute this software is hereby granted * under the terms of version 2 or any later version of the GNU General Public * License, as published by the Free Software Foundation. * * THIS SOFTWARE IS PROVIDED IN ITS "AS IS" CONDITION, WITH NO WARRANTY * WHATSOEVER. NO LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING * FROM THE USE OF THIS SOFTWARE WILL BE ACCEPTED. *//* * Author(s): Amnon Shiloh, Oren Laadan, Ariel Rosenblatt *//* Ported to OpenMosix kernel 2.6 by David Santo Orcero *//* Adapted to OpenMosix from Mosix and bugfixing by David Santo Orcero *//* irbis@orcero.org http://www.orcero.org/irbis *//* Mosix is (c) of prof. Amnon Barak http://www.mosix.org *//* Original code is (c) of prof. Amnon Barak http://www.mosix.org *//* OpenMosix is (c) of Moshe Bar http://www.openmosix.com *//* Each respective trademark is of its own owner *//* All rights reserved. *//* This software is distributed under GPL 2 *//* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTY IS ASSUMED. *//* NO LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING *//* FROM THE USE OF THIS SOFTWARE WILL BE ACCEPTED. IT CAN BURN *//* YOUR HARD DISK, ERASE ALL YOUR DATA AND BROKE DOWN YOUR *//* MICROWAVE OVEN. YOU ARE ADVISED. */#include <sys/param.h>#include <stdio.h>#include <signal.h>#include <errno.h>#include <netinet/in.h>#include <netdb.h>#include <sys/types.h>#include <sys/sysctl.h>#include <mos.h>#if _KERNELMAINVERI == 260#include <libbalancer.h>#endif/* Updated by Moshe Bar */#define STD_SPD 14000 /* standard CPU speed = 14000 */struct coms{ const char *com; char no;} coms[] ={ { "stay", D_STAY}, { "nostay", D_NOSTAY}, { "-stay", D_NOSTAY}, { "lstay", D_LSTAY}, { "nolstay", D_NOLSTAY}, { "-lstay", D_NOLSTAY}, { "block", D_BLOCK}, { "noblock", D_NOBLOCK}, { "-block", D_NOBLOCK}, { "quiet", D_QUIET}, { "noquiet", D_NOQUIET}, { "-quiet", D_NOQUIET}, { "nomfs", D_NOMFS}, { "mfs", D_MFS}, { "-mfs", D_NOMFS}, { "-nomfs", D_MFS}, { "nonomfs", D_MFS}, { "expel", D_EXPEL}, { "bring", D_BRING}, { "getload", D_GETLOAD}, { "getyard", D_GETSSPEED}, { "setyard", D_SETSSPEED}, { "speedof", D_GETSPEED}, { "getspeed", D_GETSPEED}, { "getmem", D_GETMEM}, { "memory", D_GETMEM}, { "mem", D_GETMEM}, { "getrawmem", D_GETRMEM}, { "getfree", D_GETRMEM}, { "getrawfree", D_GETRMEM}, { "rawfree", D_GETRMEM}, { "getutil", D_GETUTIL}, { "util", D_GETUTIL}, { "getutilizability", D_GETUTIL}, { "utilizability", D_GETUTIL}, { "setspeed", D_SETSPEED}, { "whois", D_MOSIX_TO_IP}, { "gettune", D_GETTUNE}, { "status", D_GETSTAT}, { "stat", D_GETSTAT}, { "isup", D_GETSTAT}, { "decay", D_GETDECAY}, { "getdecay", D_GETDECAY}, { "setdecay", D_SETDECAY}, { "sdecay", D_SETDECAY}, {(char *) 0, 0},};#define s386 "i386"#define s486 "i486"#define s586 "i586"#define s686 "i686"#define s786 "i786"#define s886 "i886"#define MAXNICK 5struct speeds{ const char *model; const char *mach[MAXNICK]; int spd;} speeds[] ={ { s386, { "386/8", "80386/8", NULL, NULL, NULL}, 11}, { s386, { "386/16", "80386/16", NULL, NULL, NULL}, 16}, { s386, { "386/20", "80386/20", NULL, NULL, NULL}, 23}, { s386, { "386/25", "80386/25", NULL, NULL, NULL}, 36}, { s386, { "386/33", "80386/33", NULL, NULL, NULL}, 47}, { s386, { "386/40", "80386/40", NULL, NULL, NULL}, 60}, { s386, { "486/8", "80486/8", NULL, NULL, NULL}, 74}, { s486, { "486/25", "80486/25", NULL, NULL, NULL}, 113}, { s486, { "486/40", "80486/40", NULL, NULL, NULL}, 175}, { s486, { "486/50", "80486/50", NULL, NULL, NULL}, 215}, { s486, { "486/66", "80486/66", NULL, NULL, NULL}, 270}, { s486, { "486/75", "80486/75", NULL, NULL, NULL}, 323}, { s486, { "486/100", "80486/100", NULL, NULL, NULL}, 422}, { s586, { "PENTIUM/8", "P/8", "80586/8", "P5/8", "586/8"}, 338}, { s586, { "PENTIUM/60", "P/60", "80586/60", "P5/60", "586/60"}, 597}, { s586, { "PENTIUM/66", "P/66", "80586/66", "P5/66", "586/66"}, 657}, { s586, { "PENTIUM/75", "P/75", "80586/75", "P5/75", "586/75"}, 746}, { s586, { "PENTIUM/90", "P/90", "80586/90", "P5/90", "586/90"}, 895}, { s586, { "PENTIUM/100", "P/100", "80586/100", "P5/100", "586/100"}, 995}, { s586, { "PENTIUM/120", "P/120", "80586/120", "P5/120", "586/120"}, 1194}, { s586, { "PENTIUM/133", "P/133", "80586/133", "P5/133", "586/133"}, 1323}, { s586, { "PENTIUM/150", "P/150", "80586/150", "P5/150", "586/150"}, 1492}, { s586, { "PENTIUM/166", "P/166", "80586/166", "P5/166", "586/166"}, 1652}, { s586, { "PENTIUM/180", "P/180", "80586/180", "P5/180", "586/180"}, 1791}, { s686, { "PPRO/8", "PP/8", "PENTIUMPRO/8", "PENTIUM/PRO/8", "P6/8"}, 458}, { s686, { "PPRO/133", "PP/133", "PENTIUMPRO/133", "PENTIUM/PRO/133", "P6/133"}, 1328}, { s686, { "PPRO/150", "PP/150", "PENTIUMPRO/150", "PENTIUM/PRO/150", "P6/150"}, 1498}, { s686, { "PPRO/166", "PP/166", "PENTIUMPRO/166", "PENTIUM/PRO/166", "P6/166"}, 1658}, { s686, { "PPRO/180", "PP/180", "PENTIUMPRO/180", "PENTIUM/PRO/180", "P6/180"}, 1798}, { s686, { "PPRO/200", "PP/200", "PENTIUMPRO/200", "PENTIUM/PRO/200", "P6/200"}, 1997}, { s686, { "PII/233", "P2/233", "PENTIUM2/233", "PENTIUM/2/233", "P6/233"}, 2327}, { s686, { "PII/266", "P2/266", "PENTIUM2/266", "PENTIUM/2/266", "P6/266"}, 2657}, { s686, { "PII/300", "P2/300", "PENTIUM2/300", "PENTIUM/2/300", "P6/300"}, 2996}, { s686, { "PII/350", "P2/350", "PENTIUM2/350", "PENTIUM/2/350", "P6/350"}, 3495}, { s686, { "PII/400", "P2/400", "PENTIUM2/400", "PENTIUM/2/400", "P6/400"}, 3995}, { s686, { "PII/450", "P2/450", "PENTIUM2/450", "PENTIUM/2/450", "P6/450"}, 4494}, { s686, { "PII/500", "P2/500", "PENTIUM2/500", "PENTIUM/2/500", "P6/500"}, 5994}, { s786, { "PIII/450", "P3/450", "PENTIUM3/450", "PENTIUM/3/050", "P7/450"}, 4500}, { s786, { "PIII/500", "P3/500", "PENTIUM3/500", "PENTIUM/3/500", "P7/500"}, 5000}, { s786, { "PIII/550", "P3/550", "PENTIUM3/550", "PENTIUM/3/550", "P7/550"}, 5500}, { s786, { "PIII/600", "P3/600", "PENTIUM3/600", "PENTIUM/3/600", "P7/600"}, 6000}, { s786, { "PIII/650", "P3/650", "PENTIUM3/650", "PENTIUM/3/650", "P7/650"}, 6500}, { s786, { "PIII/667", "P3/667", "PENTIUM3/667", "PENTIUM/3/667", "P7/667"}, 6667}, { s786, { "PIII/700", "P3/700", "PENTIUM3/700", "PENTIUM/3/700", "P7/700"}, 7000}, { s786, { "PIII/733", "P3/733", "PENTIUM3/733", "PENTIUM/3/733", "P7/733"}, 7333}, { s786, { "PIII/750", "P3/750", "PENTIUM3/750", "PENTIUM/3/750", "P7/750"}, 7500}, { s786, { "PIII/800", "P3/800", "PENTIUM3/800", "PENTIUM/3/800", "P7/800"}, 8000}, { s786, { "PIII/866", "P3/866", "PENTIUM3/866", "PENTIUM/3/866", "P7/866"}, 8667}, { s786, { "PIII/933", "P3/933", "PENTIUM3/933", "PENTIUM/3/933", "P7/933"}, 9333}, { s786, { "PIII/1000", "P3/1000", "PENTIUM3/1000", "PENTIUM/3/1000", "P7/1000"}, 10000}, { s886, { "PIV/1300", "P4/1300", "PENTIUM4/1300", "PENTIUM/4/1300", "P8/1300"}, 13000}, { s886, { "PIV/1400", "P4/1400", "PENTIUM4/1400", "PENTIUM/4/1400", "P8/1400"}, 14000}, { s886, { "PIV/1500", "P4/1500", "PENTIUM4/1500", "PENTIUM/4/1500", "P8/1500"}, 15000}, { NULL, { NULL, NULL, NULL, NULL}, 0}};#define MOSIX_STANDARD "Pentium-III at 1GHz"const char *cdesc[] = { "Home-node overhead in processing a demand-page", "Remote overhead in processing a demand-page", "Home-node overhead in processing a system call", "Remote overhead in processing a system call", "Basic home-node overhead for reading data", "Home-node overhead per 1KB read", "Basic remote overhead for reading data", "Remote overhead per 1KB read", "Basic home-node overhead for writing data", "Home-node overhead per 1KB written", "Basic remote overhead for writing data", "Remote overhead per 1KB written", "Migration time of an empty process", "Extra migration time per dirty page",};#define iabs(x) ((x) >= 0 ? (x) : -(x))intmain (int na, char **argv){ register struct coms *c; int64_t ans; register char *x; register int64_t n; int64_t arg = 0; register struct speeds *sp, *bestsp = 0; register char *u; unsigned long i1, i2, i3, i4; char stop; struct hostent *he; unsigned long addr; size_t length = 0; void *resp = NULL; static int *costs; int64_t overheads_num; int64_t tot; struct decay_params dec; char address[20];#if _KERNELMAINVERI == 240 if (!msx_is_mosix ()) { fprintf (stderr, "mosctl ignored: This is not a OpenMosix system!\n"); exit (1); }#elif _KERNELMAINVERI == 260 if (!om_isopenmosix ()) { fprintf (stderr, "mosctl ignored: This is not a OpenMosix system!\n"); exit (1); }#else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -