1 /* This file implements kernel debugging functionality that is not included
2 * in the standard kernel. Available functionality includes timing of lock
3 * functions and sanity checking of the scheduling queues.
10 #include <minix/sysutil.h>
14 #define MAX_LOOP (NR_PROCS + NR_TASKS)
20 register struct proc
*xp
;
22 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
24 if (l
++ > MAX_LOOP
) panic("check error");
27 for (q
=l
=0; q
< NR_SCHED_QUEUES
; q
++) {
28 if (rdy_head
[q
] && !rdy_tail
[q
]) {
29 printf("head but no tail in %d\n", q
);
32 if (!rdy_head
[q
] && rdy_tail
[q
]) {
33 printf("tail but no head in %d\n", q
);
36 if (rdy_tail
[q
] && rdy_tail
[q
]->p_nextready
) {
37 printf("tail and tail->next not null in %d\n", q
);
40 for(xp
= rdy_head
[q
]; xp
; xp
= xp
->p_nextready
) {
41 const vir_bytes vxp
= (vir_bytes
) xp
;
43 if(vxp
< (vir_bytes
) BEG_PROC_ADDR
|| vxp
>= (vir_bytes
) END_PROC_ADDR
) {
44 printf("xp out of range\n");
47 dxp
= vxp
- (vir_bytes
) BEG_PROC_ADDR
;
48 if(dxp
% sizeof(struct proc
)) {
49 printf("xp not a real pointer");
52 if(!proc_ptr_ok(xp
)) {
53 printf("xp bogus pointer");
56 if (RTS_ISSET(xp
, RTS_SLOT_FREE
)) {
57 printf("scheduling error: dead proc q %d %d\n",
61 if (!proc_is_runnable(xp
)) {
62 printf("scheduling error: unready on runq %d proc %d\n",
66 if (xp
->p_priority
!= q
) {
67 printf("scheduling error: wrong priority q %d proc %d ep %d name %s\n",
68 q
, xp
->p_nr
, xp
->p_endpoint
, xp
->p_name
);
72 printf("scheduling error: double sched q %d proc %d\n",
77 if (!xp
->p_nextready
&& rdy_tail
[q
] != xp
) {
78 printf("sched err: last element not tail q %d proc %d\n",
83 printf("loop in schedule queue?");
90 for (xp
= BEG_PROC_ADDR
; xp
< END_PROC_ADDR
; ++xp
) {
91 if(!proc_ptr_ok(xp
)) {
92 printf("xp bogus pointer in proc table\n");
97 if(proc_is_runnable(xp
) && !xp
->p_found
) {
98 printf("sched error: ready proc %d not on queue\n", xp
->p_nr
);
100 if (l
++ > MAX_LOOP
) {
101 printf("loop in debug.c?\n");
112 rtsflagstr(const int flags
)
114 static char str
[100];
117 #define FLAG(n) if(flags & n) { strcat(str, #n " "); }
124 FLAG(RTS_SIG_PENDING
);
127 FLAG(RTS_NO_ENDPOINT
);
131 FLAG(RTS_VMREQTARGET
);
133 FLAG(RTS_NO_QUANTUM
);
139 miscflagstr(const int flags
)
141 static char str
[100];
148 FLAG(MF_KCALL_RESUME
);
154 schedulerstr(struct proc
*scheduler
)
156 if (scheduler
!= NULL
)
158 return scheduler
->p_name
;