Date: Mon, 7 Apr 2003 14:40:30 +0800 From: "David Xu" <davidxu@freebsd.org> To: "Daniel Eischen" <eischen@pcnet1.pcnet.com> Cc: freebsd-threads@freebsd.org Subject: Re: PS_BLOCKED Message-ID: <01f801c2fcd0$952c9800$f001a8c0@davidw2k> References: <Pine.GSO.4.10.10304060821060.1170-100000@pcnet1.pcnet.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] ----- Original Message ----- From: "Daniel Eischen" <eischen@pcnet1.pcnet.com> To: "David Xu" <davidxu@freebsd.org> Cc: <freebsd-threads@freebsd.org> Sent: Sunday, April 06, 2003 8:39 PM Subject: Re: PS_BLOCKED > I forgot to mention it, but I think I found a kernel bug also. > Sometimes when the kernel exports a context to the UTS the > %gs register isn't set; it doesn't seem to be saved in some > instances. I think it might only be when a kernel thread > is swapped out (without blocking). Does %gs always get saved, > even if the thread is interrupted by an interrupt? Please test the attached patch to see if %gs problem is fixed. David Xu [-- Attachment #2 --] Index: kern_thread.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_thread.c,v retrieving revision 1.112 diff -u -r1.112 kern_thread.c --- kern_thread.c 2 Apr 2003 23:53:29 -0000 1.112 +++ kern_thread.c 7 Apr 2003 06:35:08 -0000 @@ -1242,7 +1242,9 @@ PROC_UNLOCK(p); td->td_kse = NULL; td->td_state = TDS_INACTIVE; +#if 0 td->td_proc = NULL; +#endif td->td_ksegrp = NULL; td->td_last_kse = NULL; PCPU_SET(deadthread, td); @@ -1395,13 +1397,6 @@ bzero(&spare->td_startzero, (unsigned)RANGEOF(struct thread, td_startzero, td_endzero)); spare->td_proc = td->td_proc; - /* Setup PCB and fork address */ - cpu_set_upcall(spare, td->td_pcb); - /* - * XXXKSE do we really need this? (default values for the - * frame). - */ - bcopy(td->td_frame, spare->td_frame, sizeof(struct trapframe)); spare->td_ucred = crhold(td->td_ucred); } @@ -1433,6 +1428,9 @@ bcopy(&td->td_startcopy, &td2->td_startcopy, (unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy)); thread_link(td2, ku->ku_ksegrp); + /* inherit blocked thread's context */ + bcopy(td->td_frame, td2->td_frame, sizeof(struct trapframe)); + cpu_set_upcall(td2, td->td_pcb); /* Let the new thread become owner of the upcall */ ku->ku_owner = td2; td2->td_upcall = ku;help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01f801c2fcd0$952c9800$f001a8c0>
