Re: PID==0 problems

From: Pavel Machek <pavel_at_nospam.org>
Date: Fri Oct 31 1997 - 11:32:40 PST

Hi!

> I guess in almost all cases, not killing your console is a
> feature. :-)

Well - no if you are trying your own great new console and can not
figure out why the old one does not die.

> Since 0 is a magic value, I believe you're right; we should start carving
> PID's at 1. I believe on wrap the scan starts above 0 (200, if memory
> serves), so that case is already covered. Note that the number of free
> PID's, which now starts at 2^32-1, must now be set to 2^32-2.

Ok, here's the diff. It is rather big diff, as everything that bitten
me at the first pass. So I
a) Added '?' command to kernel debugger
b) Added Meta key support to console (right thing as it allows you to
move by whole words in editors and shell)
c) Shortened console quite a bit by making Fxx code a bit wiser
d) [not sure this is right thing!!!] made arrows send emacs-style
escape sequences instead of vt100s proper arrow ones. I know I should
fix applications, not the console driver, but this is sooooo much
easier.
e) Small modification to wd driver - 5 sec just is not enough. (This
error did not actually bite me)

Diff is against 1.5.2, but I *think* (from a look at 1.5.2 to 1.6
diff) that it should patch cleanly to 1.6. Note that you may to kill
modifications to arrows as they are pretty emacs-centric.

                                                                Pavel

diff -ur vsta.old/src/os/dbg/dbgmain.c /c/vsta/src/os/dbg/dbgmain.c
--- vsta.old/src/os/dbg/dbgmain.c Sun Oct 8 21:49:46 1995
+++ /c/vsta/src/os/dbg/dbgmain.c Mon Oct 27 20:05:34 1997
@@ -8,7 +8,7 @@
 extern void dump_phys(), dump_virt(), dump_procs(), dump_pset(),
         dump_instr(), trace(), trapframe(), dump_vas(), dump_port(),
         dump_pview(), dump_thread(), dump_ref(), reboot(), memleaks(),
- dump_sysmsg(), dump_core();
+ dump_sysmsg(), dump_core(), help();
 extern void dbg_inport(), dbg_outport();
 static void quit(), calc(), set(), set_mem();
 extern int get_num();
@@ -46,6 +46,7 @@
         "trace", trace,
         "vas", dump_vas,
         "writemem", set_mem,
+ "?", help,
         0, 0
 };
 
@@ -137,6 +138,20 @@
         x = get_num(str);
         printf("%s 0x%x %d\n", symloc(x), x, x);
 }
+/*
+ * help()
+ * List all commands
+ */
+static void
+help(void)
+{
+ int x;
+
+ printf( "Available commands: " );
+ for (x = 0; cmdtab[x].c_name; ++x)
+ printf( "%s ", cmdtab[x].c_name );
+ printf( "\n" );
+}
 
 /*
  * do_cmd()
@@ -161,7 +176,7 @@
                 }
         }
         if (matches == 0) {
- printf("No such command\n");
+ printf("No such command (type ? for help)\n");
                 return;
         }
         if (matches > 1) {
diff -ur vsta.old/src/os/kern/proc.c /c/vsta/src/os/kern/proc.c
--- vsta.old/src/os/kern/proc.c Mon Apr 8 18:31:30 1996
+++ /c/vsta/src/os/kern/proc.c Mon Oct 27 13:29:40 1997
@@ -26,7 +26,8 @@
 extern lock_t runq_lock;
 
-ulong npid_free = (ulong)-1; /* # PIDs free in pool */
+ulong npid_free = (ulong)-2; /* # PIDs free in pool */
-ulong pid_nextfree = 0L; /* Next free PID number */
+ulong pid_nextfree = 1L; /* Next free PID number */
+ /* We got to use 1 or process #0 is unkillable */
 struct proc *allprocs = 0; /* List of all procs */
 sema_t pid_sema; /* Mutex for PID pool and proc lists */
 
diff -ur vsta.old/src/srv/mach/cons2/isr.c /c/vsta/src/srv/mach/cons2/isr.c
--- vsta.old/src/srv/mach/cons2/isr.c Tue Jan 30 08:32:36 1996
+++ /c/vsta/src/srv/mach/cons2/isr.c Tue Oct 28 20:30:12 1997
@@ -12,6 +12,9 @@
         capstoggle = 0, /* For toggling effect of CAPS */
         numtoggle = 0, /* ...NUM lock */
         isE0 = 0; /* Prefix for extended keys (FN1, etc.) */
+
+#define C( x ) x & 0x1f /* Turn key into ctrl-one */
+#define M( x ) x | 0x80 /* Turn key into meta key, do not use for 0 */
 
 /* Map scan codes to ASCII, one table for normal, one for shifted */
 static char normal[] = {
@@ -82,11 +85,19 @@
 #endif
 
         /*
+ * Meta keys are badly needed - if Alt is pressed,
+ * it sends ESC before actual character.
+ */
+
+ if (alt || (ch&0x80))
+ kbd_enqueue(s, 033);
+
+ /*
          * Hand off straight data now. The keyboard always enters
          * data for the virtual screen currently being displayed
          * on the hardware screen.
          */
- kbd_enqueue(s, ch);
+ kbd_enqueue(s, ch&0x7f);
 }
 
 /*
@@ -113,26 +124,29 @@
 static int
 cursor_key(struct screen *s, uchar c)
 {
- char *cp;
+ char buf[5];
+ char *cp = buf;
+ cp[0] = ' ';
+ cp[1] = 0;
 
         switch (c) {
         case 72: /* up */
- cp = "\033OA";
+ cp[0] = C('p');
                 break;
         case 80: /* down */
- cp = "\033OB";
+ cp[0] = C('n');
                 break;
         case 77: /* right */
- cp = "\033OC";
+ cp[0] = C('f');
                 break;
         case 75: /* left */
- cp = "\033OD";
+ cp[0] = C('b');
                 break;
         case 73: /* pg up */
- cp = "\033[5~";
+ cp = "\033v";
                 break;
         case 81: /* pg down */
- cp = "\033[6~";
+ cp[0] = C('v');
                 break;
         case 82: /* insert */
                 cp = "\033[2~";
@@ -172,46 +186,11 @@
 {
         char *p;
 
- switch (c) {
- case 59: /* F1 */
- p = "\033OP";
- break;
- case 60: /* F2 */
- p = "\033OQ";
- break;
- case 61: /* F3 */
- p = "\033OR";
- break;
- case 62: /* F4 */
- p = "\033OS";
- break;
- case 63: /* F5 */
- p = "\033OT";
- break;
- case 64: /* F6 */
- p = "\033OU";
- break;
- case 65: /* F7 */
- p = "\033OV";
- break;
- case 66: /* F8 */
- p = "\033OW";
- break;
- case 67: /* F9 */
- p = "\033OX";
- break;
- case 68: /* F10 */
- case 87: /* F11 */
- case 88: /* F12 */
- p = 0;
- break;
- default:
- return 0;
- }
- if (p) {
- enqueue_string(s, p);
- }
- return(1);
+ if ((c<59) || (c>68)) return 0;
+ p = "\033Q?";
+ p[2] = 'P'+c-59;
+ enqueue_string(s, p);
+ return 1;
 }
 
 /*
diff -ur vsta.old/src/srv/mach/wd/wd.c /c/vsta/src/srv/mach/wd/wd.c
--- vsta.old/src/srv/mach/wd/wd.c Thu Oct 12 07:09:46 1995
+++ /c/vsta/src/srv/mach/wd/wd.c Wed Oct 29 21:37:52 1997
@@ -376,10 +376,13 @@
          * For laptops with power management, our inportb() here can
          * cause the disk to wake up; the controller can then flag
          * a busy disk until the spinup is complete. Give it 5 seconds.
+ *
+ * I feel that 5 seconds is not enough. (My drive takes about
+ * 6, my other drive is even slower).
          */
         cyl = 0;
         while (inportb(base + WD_STATUS) & WDS_BUSY) {
- if (++cyl > 50) {
+ if (++cyl > 150) {
                         ASSERT(0, "wd_start: busy");
                 }
                 __msleep(100);

-- 
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).
Received on Sat Nov 1 01:22:57 1997

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:43 PDT