From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 29-JUN-1991 07:28:18.20
To:	ARISIA::EVERHART
CC:	
Subj:	NEWS Posting to comp.os.vms

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.101)
	 id AA25908; Sat, 29 Jun 91 07:12:20 EDT
Received: From liszt ([137.194.8.2]) by CRVAX.SRI.COM with TCP; Fri, 28 JUN 91 01:26:28 PDT
Date: Fri, 28 Jun 1991 10:24:39 EDT
From: gege@cal.enst.fr (Why not ?)
To: info-vax@kl.sri.com
Message-Id: <0094acba.c97bb7c0.627@cal.enst.fr>
Subject: NEWS Posting to comp.os.vms

Path: cal!gege
From: gege@cal.enst.fr (Why not ?)
Newsgroups: comp.os.vms
Subject: Re: Deletion of RWAST processes...
Message-ID: <36@cal.enst.fr>
Date: 28 Jun 91 10:24:22 GMT
References: <2961434@MVB.SAIC.COM> <1991Jun27.082051.403@beckman.com>
Organization: Centre de calcul, E.N.S.T. Paris
Lines: 113

In article <1991Jun27.082051.403@beckman.com>, dsroberts@beckman.com writes:
> 
>  In message, <0094aaeb.64d08240.19859>,  <SSRL01.SLAC.STANFORD.EDU>
>  asks:
>  
>>I would be grateful for advice on how to delete processes
>>that are hung in a RWAST state.
>>             Thanks in advance,
>>        A. Schach (SCHACH@LBL.BITNET)
>> 
> 
> We had an RWAST process once that had a busy mailbox open.  Using DCL, we
> opened the mailbox and wrote to it then closed it and this freed up the RWAST. 
> I have not seen it happen again, but it was a fascinating exercise.
> --

here is a hack to clear the resource wait mode bit in the PCB.
it allows process waiting for resources to disappear. it won't help
against *every* RWAST state, but common problems due to decwindows are
solved by this program.

;++
;        This little hack forces the target process to set itself in  NO RESOURCE WAIT MODE.
;
;        Author : Alain PANNETIER    TIBET - PARIS -  (1) 40 41 70 34.
;--

                .TITLE           FORCE_NO_RESOURCE_WAIT_MODE

                .LIBRARY         'SYS$SHARE:LIB.MLB'
                .LINK            'SYS$SYSTEM:SYS.STB'  /SELECTIVE_SEARCH

                .DISABLE         GLOBAL                        ;   take care of misspelling errors at assembly time

                $DSCDEF                                        ;   Descriptors structures and constants
                $IPLDEF                                        ;   Interrupt priority levels
                $PCBDEF                                        ;   Process Control Block
                $SSDEF                                         ;   System services condition values

;+
;    LOCAL STORAGE
;-
                .PSECT           DATA, WRT, NOEXE, LONG        ;

Pid_str :       .WORD            0                             ;   Empty Dynamic string descriptor
                .BYTE            DSC$K_DTYPE_T                 ;                                             
                .BYTE            DSC$K_CLASS_D                 ;
                .LONG            0                             ;

Pid:	        .BLKL            1                             ;  External pid

Prompt:         .ASCID           'Target Process PID : '       ;  Prompt

                .EXTERNAL        EXE$epid_to_pcb               ;  Gets the PCB address from an extended pid
                .EXTERNAL        LIB$get_foreign               ;  Get/prompt for argument
                .EXTERNAL        OTS$cvt_tz_l                  ;  Converts hexadecimal text to binary

;+
;    MAIN PROGRAM
;-
                .PSECT           CODE,WRT,EXE,LONG

                .ENTRY           FORCE_NO_RESOURCE_WAIT_MODE ,^m<>

                PUSHAQ           Prompt                        ;  
                PUSHAQ           Pid_str                       ;  
                CALLS	         # 2, G^lIB$get_foreign        ;  Get the pid if not specified on command line
                BLBC             R0,1$

                PUSHAL           Pid                           ;  Convert to binary ( assumes hexa input )
                PUSHAQ           Pid_str                       ; 
                CALLS            #2,G^OTS$cvt_tz_l             ;
                BLBC             R0,1$

                $CMKRNL_S        routin = Set_norswm           ;  Kick into kernel mode

1$:	        $EXIT_S          R0                            ;  Let DCL signal returned status

;+
;       KERNEL MODE MAIN TREATMENT
;-
                .ENTRY           SET_NORSWM,^M<R2,R3,R4,R5,R6,R7,R8,R9,R10,R11>  ;  Save all GPRs
;+
;               This routine is executed in Kernel mode
;               It addresses the status field of the target processe's PCB
;-
                LOCK             lockname = SCHED,           - ;  This macro from LIB.MLB
                                 lockipl  = #IPL$_SYNCH,     - ;  Lock sheduler database
                                 savipl   = R2                 ;  Remember current IPL
                MOVL             Pid, R0                       ;  input of EXE$epid_to_pcb in R0, output in R0 as well
                JSB              G^EXE$epid_to_pcb             ;  Get corresponding PCB address
                TSTL             R0                            ;  If the PCB address returned is null, assume process disapeared
                BNEQ             1$                            ;  Else continue.
                UNLOCK           lockname = SCHED,           - ;  Unlock and 
                                 newipl   = R2                 ;  restore original IPL before returning
                MOVL             #SS$_NONEXPR, R0              ;  with appropriate status.
                RET
1$:
                BBSSI            #PCB$V_SSRWAIT, PCB$L_STS(R0), 2$ ;  Set the no resource wait mode bit in target PCB's status
2$:             UNLOCK           lockname = SCHED,           - ;  Unlock and 
                                 newipl   = R2                 ;  restore original IPL before returning
                MOVL             #SS$_NORMAL, R0               ;  with success status.
                RET                                            ;

                .END            FORCE_NO_RESOURCE_WAIT_MODE 

================================================================================
! Guillaume Gerard                ! Bitnet GEGE@FRINT51                        !
! Systems responsible             ! Email  gerard@enst.fr                      !
! French Telecom University       ! X400   C=FR AD=ATLAS PD=TELECPARIS         !
! FAX: Ha! I won !!               ! PSI    2080750412855::gerard               !
================================================================================
%SYSTEM-W-TMNYFNGRS, too many fingers on keyboard

