Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.
Clean up (or if antipodic: down) some of the msgbuf stuff. Use an inline function rather than a macro for timecounter delta. Maintain process "on-cpu" time as 64 bits of microseconds to avoid needless second rollover overhead. Avoid calling microuptime the second time in mi_switch() if we do not pass through _idle in cpu_switch() This should reduce our context-switch overhead a bit, in particular on pre-P5 and SMP systems. WARNING: Programs which muck about with struct proc in userland will have to be fixed. Reviewed, but found imperfect by: bde
This commit is contained in:
parent
4a71a2e71b
commit
e796e00de3
@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: print.c,v 1.25 1998/05/15 06:29:16 charnier Exp $";
|
||||
"$Id: print.c,v 1.26 1998/05/25 05:07:18 steve Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -446,35 +446,35 @@ cputime(k, ve)
|
||||
VARENT *ve;
|
||||
{
|
||||
VAR *v;
|
||||
int64_t sec;
|
||||
long secs;
|
||||
long psecs; /* "parts" of a second. first micro, then centi */
|
||||
char obuff[128];
|
||||
|
||||
v = ve->var;
|
||||
if (KI_PROC(k)->p_stat == SZOMB || !k->ki_u.u_valid) {
|
||||
secs = 0;
|
||||
psecs = 0;
|
||||
sec = 0;
|
||||
} else {
|
||||
/*
|
||||
* This counts time spent handling interrupts. We could
|
||||
* fix this, but it is not 100% trivial (and interrupt
|
||||
* time fractions only work on the sparc anyway). XXX
|
||||
*/
|
||||
secs = KI_PROC(k)->p_rtime.tv_sec;
|
||||
psecs = KI_PROC(k)->p_rtime.tv_usec;
|
||||
sec = KI_PROC(k)->p_runtime;
|
||||
if (sumrusage) {
|
||||
secs += k->ki_u.u_cru.ru_utime.tv_sec +
|
||||
k->ki_u.u_cru.ru_stime.tv_sec;
|
||||
psecs += k->ki_u.u_cru.ru_utime.tv_usec +
|
||||
sec += (k->ki_u.u_cru.ru_utime.tv_sec +
|
||||
k->ki_u.u_cru.ru_stime.tv_sec) *
|
||||
(int64_t)1000000;
|
||||
sec += k->ki_u.u_cru.ru_utime.tv_usec +
|
||||
k->ki_u.u_cru.ru_stime.tv_usec;
|
||||
}
|
||||
/*
|
||||
* round and scale to 100's
|
||||
*/
|
||||
psecs = (psecs + 5000) / 10000;
|
||||
secs += psecs / 100;
|
||||
psecs = psecs % 100;
|
||||
}
|
||||
/*
|
||||
* round and scale to 100's
|
||||
*/
|
||||
sec = (sec + 5000) / 10000;
|
||||
secs = sec / 100;
|
||||
psecs = sec % 100;
|
||||
(void)snprintf(obuff, sizeof(obuff),
|
||||
"%3ld:%02ld.%02ld", secs/60, secs%60, psecs);
|
||||
(void)printf("%*s", v->width, obuff);
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.72 1998/05/12 18:37:10 dyson Exp $
|
||||
* $Id: swtch.s,v 1.73 1998/05/19 20:59:07 dufault Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -251,6 +251,10 @@ rem3id: .asciz "remrq.id"
|
||||
*/
|
||||
ALIGN_TEXT
|
||||
_idle:
|
||||
xorl %eax,%eax
|
||||
movl %eax, _switchtime
|
||||
movl %eax, _switchtime+4
|
||||
|
||||
#ifdef SMP
|
||||
/* when called, we have the mplock, intr disabled */
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: exception.s,v 1.51 1998/04/17 22:36:27 des Exp $
|
||||
* $Id: exception.s,v 1.52 1998/05/17 11:51:53 phk Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -344,7 +344,7 @@ IDTVEC(int0x80_syscall)
|
||||
ENTRY(fork_trampoline)
|
||||
call _spl0
|
||||
movl _curproc,%eax
|
||||
addl $P_RUNTIME,%eax
|
||||
addl $P_SWITCHTIME,%eax
|
||||
pushl %eax
|
||||
call _microuptime
|
||||
popl %eax
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: exception.s,v 1.51 1998/04/17 22:36:27 des Exp $
|
||||
* $Id: exception.s,v 1.52 1998/05/17 11:51:53 phk Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -344,7 +344,7 @@ IDTVEC(int0x80_syscall)
|
||||
ENTRY(fork_trampoline)
|
||||
call _spl0
|
||||
movl _curproc,%eax
|
||||
addl $P_RUNTIME,%eax
|
||||
addl $P_SWITCHTIME,%eax
|
||||
pushl %eax
|
||||
call _microuptime
|
||||
popl %eax
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
|
||||
* $Id: genassym.c,v 1.56 1998/05/17 22:12:07 tegge Exp $
|
||||
* $Id: genassym.c,v 1.57 1998/05/17 23:08:03 tegge Exp $
|
||||
*/
|
||||
|
||||
#include "opt_vm86.h"
|
||||
@ -106,7 +106,7 @@ main()
|
||||
printf("#define\tP_WCHAN %p\n", &p->p_wchan);
|
||||
printf("#define\tP_FLAG %p\n", &p->p_flag);
|
||||
printf("#define\tP_PID %p\n", &p->p_pid);
|
||||
printf("#define\tP_RUNTIME %p\n", &p->p_runtime);
|
||||
printf("#define\tP_SWITCHTIME %p\n", &p->p_switchtime);
|
||||
#ifdef SMP
|
||||
printf("#define\tP_ONCPU %p\n", &p->p_oncpu);
|
||||
printf("#define\tP_LASTCPU %p\n", &p->p_lastcpu);
|
||||
@ -208,6 +208,7 @@ main()
|
||||
printf("#define\tGD_NPXPROC %d\n", &globaldata->npxproc);
|
||||
printf("#define\tGD_CURPCB %d\n", &globaldata->curpcb);
|
||||
printf("#define\tGD_COMMON_TSS %d\n", &globaldata->common_tss);
|
||||
printf("#define\tGD_SWITCHTIME %d\n", &globaldata->switchtime);
|
||||
#ifdef VM86
|
||||
printf("#define\tGD_COMMON_TSSD %d\n", &globaldata->common_tssd);
|
||||
printf("#define\tGD_PRIVATE_TSS %d\n", &globaldata->private_tss);
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.295 1998/05/19 00:00:09 tegge Exp $
|
||||
* $Id: machdep.c,v 1.296 1998/05/19 08:58:46 phk Exp $
|
||||
*/
|
||||
|
||||
#include "apm.h"
|
||||
@ -146,7 +146,6 @@ int bouncepages = 0;
|
||||
#endif
|
||||
#endif /* BOUNCE_BUFFERS */
|
||||
|
||||
int msgbufmapped = 0; /* set when safe to use msgbuf */
|
||||
int _udatasel, _ucodesel;
|
||||
u_int atdevbase;
|
||||
|
||||
@ -1525,15 +1524,7 @@ init386(first)
|
||||
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp + off,
|
||||
avail_end + off, VM_PROT_ALL, TRUE);
|
||||
|
||||
cp = (char *)msgbufp;
|
||||
msgbufp = (struct msgbuf *) (cp + MSGBUF_SIZE - sizeof(*msgbufp));
|
||||
if (msgbufp->msg_magic != MSG_MAGIC || msgbufp->msg_ptr != cp) {
|
||||
bzero(cp, MSGBUF_SIZE);
|
||||
msgbufp->msg_magic = MSG_MAGIC;
|
||||
msgbufp->msg_size = (char *)msgbufp - cp;
|
||||
msgbufp->msg_ptr = cp;
|
||||
}
|
||||
msgbufmapped = 1;
|
||||
msgbufinit(msgbufp, MSGBUF_SIZE);
|
||||
|
||||
/* make a call gate to reenter kernel with */
|
||||
gdp = &ldt[LSYS5CALLS_SEL].gd;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.72 1998/05/12 18:37:10 dyson Exp $
|
||||
* $Id: swtch.s,v 1.73 1998/05/19 20:59:07 dufault Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -251,6 +251,10 @@ rem3id: .asciz "remrq.id"
|
||||
*/
|
||||
ALIGN_TEXT
|
||||
_idle:
|
||||
xorl %eax,%eax
|
||||
movl %eax, _switchtime
|
||||
movl %eax, _switchtime+4
|
||||
|
||||
#ifdef SMP
|
||||
/* when called, we have the mplock, intr disabled */
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.119 1998/04/05 01:04:48 tegge Exp $
|
||||
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1129,7 +1129,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
|
||||
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
i8254_get_timecount(void)
|
||||
{
|
||||
u_int count;
|
||||
@ -1158,7 +1158,7 @@ i8254_get_timecount(void)
|
||||
return (count);
|
||||
}
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
tsc_get_timecount(void)
|
||||
{
|
||||
return (rdtsc());
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: globaldata.h,v 1.3 1998/05/17 18:53:07 tegge Exp $
|
||||
* $Id: globaldata.h,v 1.4 1998/05/17 23:08:02 tegge Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,6 +43,7 @@ struct globaldata {
|
||||
struct proc *npxproc;
|
||||
struct pcb *curpcb;
|
||||
struct i386tss common_tss;
|
||||
struct timeval switchtime;
|
||||
#ifdef VM86
|
||||
struct segment_descriptor common_tssd;
|
||||
u_int private_tss;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.119 1998/04/05 01:04:48 tegge Exp $
|
||||
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1129,7 +1129,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
|
||||
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
i8254_get_timecount(void)
|
||||
{
|
||||
u_int count;
|
||||
@ -1158,7 +1158,7 @@ i8254_get_timecount(void)
|
||||
return (count);
|
||||
}
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
tsc_get_timecount(void)
|
||||
{
|
||||
return (rdtsc());
|
||||
|
@ -23,7 +23,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: db_print.c,v 1.15 1998/05/19 11:02:23 phk Exp $
|
||||
* $Id: db_print.c,v 1.16 1998/05/19 18:42:06 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -35,8 +35,6 @@
|
||||
* Miscellaneous printing.
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/msgbuf.h>
|
||||
|
||||
#include <ddb/ddb.h>
|
||||
#include <ddb/db_variables.h>
|
||||
@ -67,27 +65,3 @@ db_show_regs(dummy1, dummy2, dummy3, dummy4)
|
||||
db_print_loc_and_inst(PC_REGS(DDB_REGS));
|
||||
}
|
||||
|
||||
|
||||
DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if (!msgbufmapped) {
|
||||
db_printf("msgbuf not mapped yet\n");
|
||||
return;
|
||||
}
|
||||
db_printf("msgbufp = %p\n", msgbufp);
|
||||
db_printf("magic = %x, size = %d, r= %d, w = %d, ptr = %p\n",
|
||||
msgbufp->msg_magic,
|
||||
msgbufp->msg_size,
|
||||
msgbufp->msg_bufr,
|
||||
msgbufp->msg_bufx,
|
||||
msgbufp->msg_ptr);
|
||||
for (i = 0; i < msgbufp->msg_size; i++) {
|
||||
j = msgbufp->msg_ptr[(i + msgbufp->msg_bufr) % msgbufp->msg_size];
|
||||
if (j)
|
||||
db_printf("%c", j);
|
||||
}
|
||||
db_printf("\n");
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: exception.s,v 1.51 1998/04/17 22:36:27 des Exp $
|
||||
* $Id: exception.s,v 1.52 1998/05/17 11:51:53 phk Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -344,7 +344,7 @@ IDTVEC(int0x80_syscall)
|
||||
ENTRY(fork_trampoline)
|
||||
call _spl0
|
||||
movl _curproc,%eax
|
||||
addl $P_RUNTIME,%eax
|
||||
addl $P_SWITCHTIME,%eax
|
||||
pushl %eax
|
||||
call _microuptime
|
||||
popl %eax
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
|
||||
* $Id: genassym.c,v 1.56 1998/05/17 22:12:07 tegge Exp $
|
||||
* $Id: genassym.c,v 1.57 1998/05/17 23:08:03 tegge Exp $
|
||||
*/
|
||||
|
||||
#include "opt_vm86.h"
|
||||
@ -106,7 +106,7 @@ main()
|
||||
printf("#define\tP_WCHAN %p\n", &p->p_wchan);
|
||||
printf("#define\tP_FLAG %p\n", &p->p_flag);
|
||||
printf("#define\tP_PID %p\n", &p->p_pid);
|
||||
printf("#define\tP_RUNTIME %p\n", &p->p_runtime);
|
||||
printf("#define\tP_SWITCHTIME %p\n", &p->p_switchtime);
|
||||
#ifdef SMP
|
||||
printf("#define\tP_ONCPU %p\n", &p->p_oncpu);
|
||||
printf("#define\tP_LASTCPU %p\n", &p->p_lastcpu);
|
||||
@ -208,6 +208,7 @@ main()
|
||||
printf("#define\tGD_NPXPROC %d\n", &globaldata->npxproc);
|
||||
printf("#define\tGD_CURPCB %d\n", &globaldata->curpcb);
|
||||
printf("#define\tGD_COMMON_TSS %d\n", &globaldata->common_tss);
|
||||
printf("#define\tGD_SWITCHTIME %d\n", &globaldata->switchtime);
|
||||
#ifdef VM86
|
||||
printf("#define\tGD_COMMON_TSSD %d\n", &globaldata->common_tssd);
|
||||
printf("#define\tGD_PRIVATE_TSS %d\n", &globaldata->private_tss);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: globals.s,v 1.3 1998/05/17 18:53:19 tegge Exp $
|
||||
* $Id: globals.s,v 1.4 1998/05/17 23:08:03 tegge Exp $
|
||||
*/
|
||||
|
||||
#include "opt_vm86.h"
|
||||
@ -68,11 +68,12 @@
|
||||
globaldata:
|
||||
.space GD_SIZEOF /* in data segment */
|
||||
#endif
|
||||
.globl _curproc,_curpcb,_npxproc,_common_tss
|
||||
.globl _curproc,_curpcb,_npxproc,_common_tss,_switchtime
|
||||
.set _curproc,globaldata + GD_CURPROC
|
||||
.set _curpcb,globaldata + GD_CURPCB
|
||||
.set _npxproc,globaldata + GD_NPXPROC
|
||||
.set _common_tss,globaldata + GD_COMMON_TSS
|
||||
.set _switchtime,globaldata + GD_SWITCHTIME
|
||||
|
||||
#ifdef VM86
|
||||
.globl _common_tssd,_private_tss,_my_tr
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.295 1998/05/19 00:00:09 tegge Exp $
|
||||
* $Id: machdep.c,v 1.296 1998/05/19 08:58:46 phk Exp $
|
||||
*/
|
||||
|
||||
#include "apm.h"
|
||||
@ -146,7 +146,6 @@ int bouncepages = 0;
|
||||
#endif
|
||||
#endif /* BOUNCE_BUFFERS */
|
||||
|
||||
int msgbufmapped = 0; /* set when safe to use msgbuf */
|
||||
int _udatasel, _ucodesel;
|
||||
u_int atdevbase;
|
||||
|
||||
@ -1525,15 +1524,7 @@ init386(first)
|
||||
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp + off,
|
||||
avail_end + off, VM_PROT_ALL, TRUE);
|
||||
|
||||
cp = (char *)msgbufp;
|
||||
msgbufp = (struct msgbuf *) (cp + MSGBUF_SIZE - sizeof(*msgbufp));
|
||||
if (msgbufp->msg_magic != MSG_MAGIC || msgbufp->msg_ptr != cp) {
|
||||
bzero(cp, MSGBUF_SIZE);
|
||||
msgbufp->msg_magic = MSG_MAGIC;
|
||||
msgbufp->msg_size = (char *)msgbufp - cp;
|
||||
msgbufp->msg_ptr = cp;
|
||||
}
|
||||
msgbufmapped = 1;
|
||||
msgbufinit(msgbufp, MSGBUF_SIZE);
|
||||
|
||||
/* make a call gate to reenter kernel with */
|
||||
gdp = &ldt[LSYS5CALLS_SEL].gd;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: swtch.s,v 1.72 1998/05/12 18:37:10 dyson Exp $
|
||||
* $Id: swtch.s,v 1.73 1998/05/19 20:59:07 dufault Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -251,6 +251,10 @@ rem3id: .asciz "remrq.id"
|
||||
*/
|
||||
ALIGN_TEXT
|
||||
_idle:
|
||||
xorl %eax,%eax
|
||||
movl %eax, _switchtime
|
||||
movl %eax, _switchtime+4
|
||||
|
||||
#ifdef SMP
|
||||
/* when called, we have the mplock, intr disabled */
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.119 1998/04/05 01:04:48 tegge Exp $
|
||||
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1129,7 +1129,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
|
||||
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
i8254_get_timecount(void)
|
||||
{
|
||||
u_int count;
|
||||
@ -1158,7 +1158,7 @@ i8254_get_timecount(void)
|
||||
return (count);
|
||||
}
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
tsc_get_timecount(void)
|
||||
{
|
||||
return (rdtsc());
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: globaldata.h,v 1.3 1998/05/17 18:53:07 tegge Exp $
|
||||
* $Id: globaldata.h,v 1.4 1998/05/17 23:08:02 tegge Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,6 +43,7 @@ struct globaldata {
|
||||
struct proc *npxproc;
|
||||
struct pcb *curpcb;
|
||||
struct i386tss common_tss;
|
||||
struct timeval switchtime;
|
||||
#ifdef VM86
|
||||
struct segment_descriptor common_tssd;
|
||||
u_int private_tss;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: globaldata.h,v 1.3 1998/05/17 18:53:07 tegge Exp $
|
||||
* $Id: globaldata.h,v 1.4 1998/05/17 23:08:02 tegge Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,6 +43,7 @@ struct globaldata {
|
||||
struct proc *npxproc;
|
||||
struct pcb *curpcb;
|
||||
struct i386tss common_tss;
|
||||
struct timeval switchtime;
|
||||
#ifdef VM86
|
||||
struct segment_descriptor common_tssd;
|
||||
u_int private_tss;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.119 1998/04/05 01:04:48 tegge Exp $
|
||||
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1129,7 +1129,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
|
||||
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
i8254_get_timecount(void)
|
||||
{
|
||||
u_int count;
|
||||
@ -1158,7 +1158,7 @@ i8254_get_timecount(void)
|
||||
return (count);
|
||||
}
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
tsc_get_timecount(void)
|
||||
{
|
||||
return (rdtsc());
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.119 1998/04/05 01:04:48 tegge Exp $
|
||||
* $Id: clock.c,v 1.120 1998/05/19 18:48:30 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1129,7 +1129,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
|
||||
0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
i8254_get_timecount(void)
|
||||
{
|
||||
u_int count;
|
||||
@ -1158,7 +1158,7 @@ i8254_get_timecount(void)
|
||||
return (count);
|
||||
}
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
tsc_get_timecount(void)
|
||||
{
|
||||
return (rdtsc());
|
||||
|
@ -39,7 +39,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
|
||||
* $Id: init_main.c,v 1.91 1998/04/19 23:31:54 julian Exp $
|
||||
* $Id: init_main.c,v 1.92 1998/05/17 11:52:35 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_devfs.h"
|
||||
@ -377,8 +377,10 @@ proc0_init(dummy)
|
||||
limit0.pl_rlimit[RLIMIT_RSS].rlim_max = i;
|
||||
limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = i;
|
||||
limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3;
|
||||
limit0.p_cpulimit = RLIM_INFINITY;
|
||||
limit0.p_refcnt = 1;
|
||||
|
||||
|
||||
/* Allocate a prototype map so we have something to fork. */
|
||||
pmap_pinit0(&vmspace0.vm_pmap);
|
||||
p->p_vmspace = &vmspace0;
|
||||
@ -426,13 +428,13 @@ proc0_post(dummy)
|
||||
|
||||
/*
|
||||
* Now can look at time, having had a chance to verify the time
|
||||
* from the file system. Reset p->p_rtime as it may have been
|
||||
* from the file system. Reset p->p_runtime as it may have been
|
||||
* munched in mi_switch() after the time got set. Set
|
||||
* p->p_runtime to be consistent with this unmunching.
|
||||
* p->p_switchtime to be consistent with this unmunching.
|
||||
*/
|
||||
microtime(&proc0.p_stats->p_start);
|
||||
timevalclear(&proc0.p_rtime);
|
||||
microuptime(&proc0.p_runtime);
|
||||
proc0.p_runtime = 0;
|
||||
microuptime(&proc0.p_switchtime);
|
||||
|
||||
/*
|
||||
* Give the ``random'' number generator a thump.
|
||||
|
@ -39,7 +39,7 @@ static volatile int print_tci = 1;
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
|
||||
* $Id: kern_clock.c,v 1.68 1998/05/17 11:52:39 phk Exp $
|
||||
* $Id: kern_clock.c,v 1.69 1998/05/19 18:54:38 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -73,6 +73,7 @@ SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
|
||||
|
||||
static void tco_forward __P((void));
|
||||
static void tco_setscales __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_getdelta __P((struct timecounter *tc));
|
||||
|
||||
/* Some of these don't belong here, but it's easiest to concentrate them. */
|
||||
#if defined(SMP) && defined(BETTER_CLOCK)
|
||||
@ -493,8 +494,12 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
|
||||
0, 0, sysctl_kern_clockrate, "S,clockinfo","");
|
||||
|
||||
#define TC_DELTA(tc) \
|
||||
(((tc)->get_timecount() - (tc)->offset_count) & (tc)->counter_mask)
|
||||
static __inline unsigned
|
||||
tco_getdelta(struct timecounter *tc)
|
||||
{
|
||||
|
||||
return ((tc->get_timecount() - tc->offset_count) & tc->counter_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* We have four functions for looking at the clock, two for microseconds
|
||||
@ -530,7 +535,7 @@ microtime(struct timeval *tv)
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += boottime.tv_usec;
|
||||
tv->tv_sec += boottime.tv_sec;
|
||||
while (tv->tv_usec >= 1000000) {
|
||||
@ -548,7 +553,7 @@ nanotime(struct timespec *tv)
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = TC_DELTA(tc);
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
delta >>= 32;
|
||||
@ -590,7 +595,7 @@ microuptime(struct timeval *tv)
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
if (tv->tv_usec >= 1000000) {
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_sec++;
|
||||
@ -600,13 +605,13 @@ microuptime(struct timeval *tv)
|
||||
void
|
||||
nanouptime(struct timespec *tv)
|
||||
{
|
||||
u_int count;
|
||||
unsigned count;
|
||||
u_int64_t delta;
|
||||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = TC_DELTA(tc);
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
delta >>= 32;
|
||||
@ -725,7 +730,7 @@ sync_other_counter(void)
|
||||
tco = tc->other;
|
||||
*tc = *timecounter;
|
||||
tc->other = tco;
|
||||
delta = TC_DELTA(tc);
|
||||
delta = tco_getdelta(tc);
|
||||
tc->offset_count += delta;
|
||||
tc->offset_count &= tc->counter_mask;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f;
|
||||
@ -799,10 +804,10 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW,
|
||||
* timeservices.
|
||||
*/
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
dummy_get_timecount(void)
|
||||
{
|
||||
static u_int now;
|
||||
static unsigned now;
|
||||
return (++now);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
|
||||
* $Id: kern_resource.c,v 1.35 1998/04/05 02:59:10 peter Exp $
|
||||
* $Id: kern_resource.c,v 1.36 1998/05/17 11:52:43 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_compat.h"
|
||||
@ -399,6 +399,13 @@ dosetrlimit(p, which, limp)
|
||||
|
||||
switch (which) {
|
||||
|
||||
case RLIMIT_CPU:
|
||||
if (limp->rlim_cur > RLIM_INFINITY / (rlim_t)1000000)
|
||||
p->p_limit->p_cpulimit = RLIM_INFINITY;
|
||||
else
|
||||
p->p_limit->p_cpulimit =
|
||||
(rlim_t)1000000 * limp->rlim_cur;
|
||||
break;
|
||||
case RLIMIT_DATA:
|
||||
if (limp->rlim_cur > MAXDSIZ)
|
||||
limp->rlim_cur = MAXDSIZ;
|
||||
@ -485,9 +492,8 @@ calcru(p, up, sp, ip)
|
||||
struct timeval *sp;
|
||||
struct timeval *ip;
|
||||
{
|
||||
quad_t totusec;
|
||||
u_quad_t u, st, ut, it, tot;
|
||||
long sec, usec;
|
||||
int64_t totusec;
|
||||
u_int64_t u, st, ut, it, tot;
|
||||
int s;
|
||||
struct timeval tv;
|
||||
|
||||
@ -504,8 +510,7 @@ calcru(p, up, sp, ip)
|
||||
tot = 1;
|
||||
}
|
||||
|
||||
sec = p->p_rtime.tv_sec;
|
||||
usec = p->p_rtime.tv_usec;
|
||||
totusec = p->p_runtime;
|
||||
#ifdef SMP
|
||||
if (p->p_oncpu != (char)0xff) {
|
||||
#else
|
||||
@ -517,10 +522,9 @@ calcru(p, up, sp, ip)
|
||||
* quantum, which is much greater than the sampling error.
|
||||
*/
|
||||
microuptime(&tv);
|
||||
sec += tv.tv_sec - p->p_runtime.tv_sec;
|
||||
usec += tv.tv_usec - p->p_runtime.tv_usec;
|
||||
totusec += (tv.tv_usec - p->p_switchtime.tv_usec) +
|
||||
(tv.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000;
|
||||
}
|
||||
totusec = (quad_t)sec * 1000000 + usec;
|
||||
if (totusec < 0) {
|
||||
/* XXX no %qd in kernel. Truncate. */
|
||||
printf("calcru: negative time of %ld usec for pid %d (%s)\n",
|
||||
@ -602,8 +606,7 @@ limcopy(lim)
|
||||
|
||||
MALLOC(copy, struct plimit *, sizeof(struct plimit),
|
||||
M_SUBPROC, M_WAITOK);
|
||||
bcopy(lim->pl_rlimit, copy->pl_rlimit,
|
||||
sizeof(struct rlimit) * RLIM_NLIMITS);
|
||||
bcopy(lim->pl_rlimit, copy->pl_rlimit, sizeof(struct plimit));
|
||||
copy->p_lflags = 0;
|
||||
copy->p_refcnt = 1;
|
||||
return (copy);
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
|
||||
* $Id: kern_synch.c,v 1.55 1998/05/17 11:52:45 phk Exp $
|
||||
* $Id: kern_synch.c,v 1.56 1998/05/17 22:12:14 tegge Exp $
|
||||
*/
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
@ -599,9 +599,7 @@ mi_switch()
|
||||
{
|
||||
register struct proc *p = curproc; /* XXX */
|
||||
register struct rlimit *rlim;
|
||||
register long s, u;
|
||||
int x;
|
||||
struct timeval tv;
|
||||
|
||||
/*
|
||||
* XXX this spl is almost unnecessary. It is partly to allow for
|
||||
@ -630,36 +628,23 @@ mi_switch()
|
||||
* Compute the amount of time during which the current
|
||||
* process was running, and add that to its total so far.
|
||||
*/
|
||||
microuptime(&tv);
|
||||
u = p->p_rtime.tv_usec + (tv.tv_usec - p->p_runtime.tv_usec);
|
||||
s = p->p_rtime.tv_sec + (tv.tv_sec - p->p_runtime.tv_sec);
|
||||
if (u < 0) {
|
||||
u += 1000000;
|
||||
s--;
|
||||
} else if (u >= 1000000) {
|
||||
u -= 1000000;
|
||||
s++;
|
||||
}
|
||||
#ifdef SMP
|
||||
if (s < 0)
|
||||
s = u = 0;
|
||||
#endif
|
||||
p->p_rtime.tv_usec = u;
|
||||
p->p_rtime.tv_sec = s;
|
||||
microuptime(&switchtime);
|
||||
p->p_runtime += (switchtime.tv_usec - p->p_switchtime.tv_usec) +
|
||||
(switchtime.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000;
|
||||
|
||||
/*
|
||||
* Check if the process exceeds its cpu resource allocation.
|
||||
* If over max, kill it.
|
||||
*/
|
||||
if (p->p_stat != SZOMB) {
|
||||
if (p->p_stat != SZOMB && p->p_runtime > p->p_limit->p_cpulimit) {
|
||||
rlim = &p->p_rlimit[RLIMIT_CPU];
|
||||
if (s >= rlim->rlim_cur) {
|
||||
if (s >= rlim->rlim_max)
|
||||
killproc(p, "exceeded maximum CPU limit");
|
||||
else {
|
||||
psignal(p, SIGXCPU);
|
||||
if (rlim->rlim_cur < rlim->rlim_max)
|
||||
rlim->rlim_cur += 5;
|
||||
if (p->p_runtime / (rlim_t)1000000 >= rlim->rlim_max) {
|
||||
killproc(p, "exceeded maximum CPU limit");
|
||||
} else {
|
||||
psignal(p, SIGXCPU);
|
||||
if (rlim->rlim_cur < rlim->rlim_max) {
|
||||
/* XXX: we should make a private copy */
|
||||
rlim->rlim_cur += 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -669,7 +654,10 @@ mi_switch()
|
||||
*/
|
||||
cnt.v_swtch++;
|
||||
cpu_switch(p);
|
||||
microuptime(&p->p_runtime);
|
||||
if (switchtime.tv_sec)
|
||||
p->p_switchtime = switchtime;
|
||||
else
|
||||
microuptime(&p->p_switchtime);
|
||||
splx(x);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ static volatile int print_tci = 1;
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
|
||||
* $Id: kern_clock.c,v 1.68 1998/05/17 11:52:39 phk Exp $
|
||||
* $Id: kern_clock.c,v 1.69 1998/05/19 18:54:38 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -73,6 +73,7 @@ SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
|
||||
|
||||
static void tco_forward __P((void));
|
||||
static void tco_setscales __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_getdelta __P((struct timecounter *tc));
|
||||
|
||||
/* Some of these don't belong here, but it's easiest to concentrate them. */
|
||||
#if defined(SMP) && defined(BETTER_CLOCK)
|
||||
@ -493,8 +494,12 @@ sysctl_kern_clockrate SYSCTL_HANDLER_ARGS
|
||||
SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
|
||||
0, 0, sysctl_kern_clockrate, "S,clockinfo","");
|
||||
|
||||
#define TC_DELTA(tc) \
|
||||
(((tc)->get_timecount() - (tc)->offset_count) & (tc)->counter_mask)
|
||||
static __inline unsigned
|
||||
tco_getdelta(struct timecounter *tc)
|
||||
{
|
||||
|
||||
return ((tc->get_timecount() - tc->offset_count) & tc->counter_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* We have four functions for looking at the clock, two for microseconds
|
||||
@ -530,7 +535,7 @@ microtime(struct timeval *tv)
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += boottime.tv_usec;
|
||||
tv->tv_sec += boottime.tv_sec;
|
||||
while (tv->tv_usec >= 1000000) {
|
||||
@ -548,7 +553,7 @@ nanotime(struct timespec *tv)
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = TC_DELTA(tc);
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
delta >>= 32;
|
||||
@ -590,7 +595,7 @@ microuptime(struct timeval *tv)
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)TC_DELTA(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
if (tv->tv_usec >= 1000000) {
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_sec++;
|
||||
@ -600,13 +605,13 @@ microuptime(struct timeval *tv)
|
||||
void
|
||||
nanouptime(struct timespec *tv)
|
||||
{
|
||||
u_int count;
|
||||
unsigned count;
|
||||
u_int64_t delta;
|
||||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = TC_DELTA(tc);
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
delta >>= 32;
|
||||
@ -725,7 +730,7 @@ sync_other_counter(void)
|
||||
tco = tc->other;
|
||||
*tc = *timecounter;
|
||||
tc->other = tco;
|
||||
delta = TC_DELTA(tc);
|
||||
delta = tco_getdelta(tc);
|
||||
tc->offset_count += delta;
|
||||
tc->offset_count &= tc->counter_mask;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f;
|
||||
@ -799,10 +804,10 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW,
|
||||
* timeservices.
|
||||
*/
|
||||
|
||||
static u_int
|
||||
static unsigned
|
||||
dummy_get_timecount(void)
|
||||
{
|
||||
static u_int now;
|
||||
static unsigned now;
|
||||
return (++now);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)subr_log.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: subr_log.c,v 1.27 1998/02/20 13:46:56 bde Exp $
|
||||
* $Id: subr_log.c,v 1.28 1998/05/19 08:58:51 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -39,7 +39,6 @@
|
||||
*/
|
||||
|
||||
#include "opt_devfs.h"
|
||||
#include "opt_msgbuf.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -269,5 +268,3 @@ log_drvinit(unused)
|
||||
}
|
||||
|
||||
SYSINIT(logdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,log_drvinit,NULL)
|
||||
|
||||
|
||||
|
@ -36,13 +36,12 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
|
||||
* $Id: subr_prf.c,v 1.44 1997/12/28 05:03:33 bde Exp $
|
||||
* $Id: subr_prf.c,v 1.45 1998/05/19 08:58:51 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_msgbuf.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/msgbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
@ -71,6 +70,7 @@ static void putchar __P((int ch, void *arg));
|
||||
static char *ksprintn __P((u_long num, int base, int *len));
|
||||
|
||||
static int consintr = 1; /* Ok to handle console interrupts? */
|
||||
static int msgbufmapped; /* Set when safe to use msgbuf */
|
||||
|
||||
/*
|
||||
* Warn that a system table is full.
|
||||
@ -275,7 +275,7 @@ vprintf(const char *fmt, va_list ap)
|
||||
|
||||
/*
|
||||
* Print a character on console or users terminal. If destination is
|
||||
* the console then the last MSGBUFS characters are saved in msgbuf for
|
||||
* the console then the last bunch of characters are saved in msgbuf for
|
||||
* inspection later.
|
||||
*/
|
||||
static void
|
||||
@ -598,3 +598,44 @@ msglogchar(int c, void *dummyarg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
msgbufinit(void *ptr, size_t size)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = (char *)ptr;
|
||||
msgbufp = (struct msgbuf *) (cp + size - sizeof(*msgbufp));
|
||||
if (msgbufp->msg_magic != MSG_MAGIC || msgbufp->msg_ptr != cp) {
|
||||
bzero(cp, size);
|
||||
msgbufp->msg_magic = MSG_MAGIC;
|
||||
msgbufp->msg_size = (char *)msgbufp - cp;
|
||||
msgbufp->msg_ptr = cp;
|
||||
}
|
||||
msgbufmapped = 1;
|
||||
}
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
|
||||
DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (!msgbufmapped) {
|
||||
db_printf("msgbuf not mapped yet\n");
|
||||
return;
|
||||
}
|
||||
db_printf("msgbufp = %p\n", msgbufp);
|
||||
db_printf("magic = %x, size = %d, r= %d, w = %d, ptr = %p\n",
|
||||
msgbufp->msg_magic, msgbufp->msg_size, msgbufp->msg_bufr,
|
||||
msgbufp->msg_bufx, msgbufp->msg_ptr);
|
||||
for (i = 0; i < msgbufp->msg_size; i++) {
|
||||
j = (i + msgbufp->msg_bufr) % msgbufp->msg_size;
|
||||
db_printf("%c", msgbufp->msg_ptr[j]);
|
||||
}
|
||||
db_printf("\n");
|
||||
}
|
||||
|
||||
#endif /* DDB */
|
||||
|
@ -31,27 +31,30 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: msgbuf.h,v 1.9 1997/02/22 09:45:37 peter Exp $
|
||||
* $Id: msgbuf.h,v 1.10 1998/05/19 08:58:35 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MSGBUF_H_
|
||||
#define _SYS_MSGBUF_H_
|
||||
|
||||
#if defined(KERNEL) && !defined(MSGBUF_SIZE)
|
||||
#define MSGBUF_SIZE 8192
|
||||
#endif
|
||||
|
||||
struct msgbuf {
|
||||
#define MSG_MAGIC 0x063062
|
||||
unsigned int msg_magic;
|
||||
unsigned int msg_size; /* MSG_BSIZE */
|
||||
unsigned int msg_size; /* size of buffer area */
|
||||
unsigned int msg_bufx; /* write pointer */
|
||||
unsigned int msg_bufr; /* read pointer */
|
||||
char * msg_ptr; /* pointer to buffer */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
extern int msgbufmapped;
|
||||
extern struct msgbuf *msgbufp;
|
||||
void msgbufinit __P((void *ptr, size_t size));
|
||||
|
||||
#if !defined(MSGBUF_SIZE)
|
||||
#define MSGBUF_SIZE 8192
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)proc.h 8.15 (Berkeley) 5/19/95
|
||||
* $Id: proc.h,v 1.56 1998/03/28 10:33:23 bde Exp $
|
||||
* $Id: proc.h,v 1.57 1998/04/04 13:26:14 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_PROC_H_
|
||||
@ -134,8 +134,8 @@ struct proc {
|
||||
u_int p_slptime; /* Time since last blocked. */
|
||||
|
||||
struct itimerval p_realtimer; /* Alarm timer. */
|
||||
struct timeval p_rtime; /* Real time. */
|
||||
struct timeval p_runtime; /* When last scheduled */
|
||||
u_int64_t p_runtime; /* Real time in microsec. */
|
||||
struct timeval p_switchtime; /* When last scheduled */
|
||||
u_quad_t p_uticks; /* Statclock hits in user mode. */
|
||||
u_quad_t p_sticks; /* Statclock hits in system mode. */
|
||||
u_quad_t p_iticks; /* Statclock hits processing intr. */
|
||||
@ -300,6 +300,7 @@ extern struct proc *curproc; /* Current running proc. */
|
||||
extern struct proc proc0; /* Process slot for swapper. */
|
||||
extern int nprocs, maxproc; /* Current and max number of procs. */
|
||||
extern int maxprocperuid; /* Max procs per uid. */
|
||||
extern struct timeval switchtime; /* Uptime at last context switch */
|
||||
|
||||
LIST_HEAD(proclist, proc);
|
||||
extern struct proclist allproc; /* List of all processes. */
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
|
||||
* $Id: resourcevar.h,v 1.10 1997/02/22 09:45:46 peter Exp $
|
||||
* $Id: resourcevar.h,v 1.11 1998/03/28 10:33:23 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_RESOURCEVAR_H_
|
||||
@ -77,6 +77,7 @@ struct plimit {
|
||||
#define PL_SHAREMOD 0x01 /* modifications are shared */
|
||||
int p_lflags;
|
||||
int p_refcnt; /* number of references */
|
||||
rlim_t p_cpulimit; /* current cpu limit in usec */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)time.h 8.5 (Berkeley) 5/4/95
|
||||
* $Id: time.h,v 1.27 1998/05/17 11:53:40 phk Exp $
|
||||
* $Id: time.h,v 1.28 1998/05/19 18:55:02 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H_
|
||||
@ -129,12 +129,12 @@ struct timezone {
|
||||
*/
|
||||
|
||||
struct timecounter;
|
||||
typedef u_int timecounter_get_t __P((void));
|
||||
typedef unsigned timecounter_get_t __P((void));
|
||||
|
||||
struct timecounter {
|
||||
/* These fields must be initialized by the driver. */
|
||||
timecounter_get_t *get_timecount;
|
||||
u_int counter_mask;
|
||||
unsigned counter_mask;
|
||||
u_int32_t frequency;
|
||||
char *name;
|
||||
/* These fields will be managed by the generic code. */
|
||||
@ -143,7 +143,7 @@ struct timecounter {
|
||||
u_int32_t scale_micro;
|
||||
u_int32_t scale_nano_i;
|
||||
u_int32_t scale_nano_f;
|
||||
u_int offset_count;
|
||||
unsigned offset_count;
|
||||
u_int32_t offset_sec;
|
||||
u_int32_t offset_micro;
|
||||
u_int64_t offset_nano;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)time.h 8.5 (Berkeley) 5/4/95
|
||||
* $Id: time.h,v 1.27 1998/05/17 11:53:40 phk Exp $
|
||||
* $Id: time.h,v 1.28 1998/05/19 18:55:02 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H_
|
||||
@ -129,12 +129,12 @@ struct timezone {
|
||||
*/
|
||||
|
||||
struct timecounter;
|
||||
typedef u_int timecounter_get_t __P((void));
|
||||
typedef unsigned timecounter_get_t __P((void));
|
||||
|
||||
struct timecounter {
|
||||
/* These fields must be initialized by the driver. */
|
||||
timecounter_get_t *get_timecount;
|
||||
u_int counter_mask;
|
||||
unsigned counter_mask;
|
||||
u_int32_t frequency;
|
||||
char *name;
|
||||
/* These fields will be managed by the generic code. */
|
||||
@ -143,7 +143,7 @@ struct timecounter {
|
||||
u_int32_t scale_micro;
|
||||
u_int32_t scale_nano_i;
|
||||
u_int32_t scale_nano_f;
|
||||
u_int offset_count;
|
||||
unsigned offset_count;
|
||||
u_int32_t offset_sec;
|
||||
u_int32_t offset_micro;
|
||||
u_int64_t offset_nano;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* Steven Wallace <swallace@freebsd.org>
|
||||
* Wolfram Schneider <wosch@FreeBSD.org>
|
||||
*
|
||||
* $Id: machine.c,v 1.8 1997/10/05 21:20:56 fsmp Exp $
|
||||
* $Id: machine.c,v 1.9 1998/02/14 13:34:59 peter Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -565,7 +565,7 @@ char *(*get_userid)();
|
||||
/* This does not produce the correct results */
|
||||
cputime = PP(pp, p_uticks) + PP(pp, p_sticks) + PP(pp, p_iticks);
|
||||
#endif
|
||||
cputime = PP(pp, p_rtime).tv_sec; /* This does not count interrupts */
|
||||
cputime = PP(pp, p_runtime) / 1000000; /* This does not count interrupts */
|
||||
|
||||
/* calculate the base for cpu percentages */
|
||||
pct = pctdouble(PP(pp, p_pctcpu));
|
||||
@ -736,7 +736,7 @@ struct proc **pp2;
|
||||
if ((lresult = PP(p2, p_pctcpu) - PP(p1, p_pctcpu)) == 0)
|
||||
{
|
||||
/* use lifetime CPU usage to break the tie */
|
||||
if ((result = PP(p2, p_rtime).tv_sec - PP(p1, p_rtime).tv_sec) == 0)
|
||||
if ((result = PP(p2, p_runtime) - PP(p1, p_runtime)) == 0)
|
||||
{
|
||||
/* use process state to break the tie */
|
||||
if ((result = sorted_state[(unsigned char) PP(p2, p_stat)] -
|
||||
|
Loading…
x
Reference in New Issue
Block a user