Jump to content

KernBlock: Difference between revisions

From EDM2
Ak120 (talk | contribs)
m Ak120 moved page OS2 API:KEE:KernBlock to KernBlock
No edit summary
Line 6: Line 6:


==Parameters==
==Parameters==
; eventid : Some unique value, which is to be used by KernWakeup to unblock the thread again.


eventid
; timeout : a timeout value in milliseconds. 0xffffffff is supposedly infinite wait.  
    Some unique value, which is to be used by KernWakeup to unblock the thread again.  


timeout
; flags : One or more of the following flags:
    a timeout value in milliseconds. 0xffffffff is supposedly infinite wait.
 
flags
    One or more of the following flags:


     KEE_BLOCK_NOSIGNALS
     KEE_BLOCK_NOSIGNALS
Line 27: Line 23:
         Don't reacquire the lock (if lockptr points to a lock at all) when the KernBlock routine returns.  
         Don't reacquire the lock (if lockptr points to a lock at all) when the KernBlock routine returns.  


lockptr
; lockptr : Used when one of the three *LOCK bits is set: points to the specified lock structure  
    Used when one of the three *LOCK bits is set: points to the specified lock structure  
 
retdata
; retdata : points to a long variable that receives the value passed by the KernWakeup routine. May be NULL, in this case the value is ignored.  
    points to a long variable that receives the value passed by the KernWakeup routine. May be NULL, in this case the value is ignored.  


==Comments==
==Comments==
Line 36: Line 31:
I guess the retdata value us irrelevant for a timeout or an interrupt by a signal (return values ERROR_TIMEOUT and ERROR_INTERRUPT).  
I guess the retdata value us irrelevant for a timeout or an interrupt by a signal (return values ERROR_TIMEOUT and ERROR_INTERRUPT).  


[[Category:The OS/2 API Project]]
[[Category:Kern]]

Revision as of 02:52, 10 May 2017

Synopsis

APIRET APIENTRY KernBlock(ULONG eventid, ULONG timeout, ULONG flags, PVOID lockptr, PULONG retdata);

Description

This is an extended version of the DevHlp_ProcBlock function. Basically, you specify an arbitrary eventid and a timeout. The block may be coordinated with either an acquired spinlock or a mutexlock, as declared by the flags. The lock is released immediately before blocking, and reacquired after returning from the routine, unless the flag bit KEE_BLOCK_NOACQUIRE prevents re-acquiration. The blocked thread will hang in this routine, and can be resurrected by a signal (unless turned off with KEE_BLOCK_NOSIGNALS) or a KernWakeup with the same eventid.

Parameters

eventid
Some unique value, which is to be used by KernWakeup to unblock the thread again.
timeout
a timeout value in milliseconds. 0xffffffff is supposedly infinite wait.
flags
One or more of the following flags:
   KEE_BLOCK_NOSIGNALS
       Ignore signals, i.e. the block can be released only by end of timeout or an explicit wakeup. 
   KEE_BLOCK_SPINLOCK
       The lockptr points to an acquired KEESpinLock structure. 
   KEE_BLOCK_EXMUTEXLOCK
       The lockptr points to an acquired exclusive mutexlock structure. 
   KEE_BLOCK_SHMUTEXLOCK
       The lockptr points to an acquired shared mutexlock structure. 
   KEE_BLOCK_NOACQUIRE
       Don't reacquire the lock (if lockptr points to a lock at all) when the KernBlock routine returns. 
lockptr
Used when one of the three *LOCK bits is set: points to the specified lock structure
retdata
points to a long variable that receives the value passed by the KernWakeup routine. May be NULL, in this case the value is ignored.

Comments

The KEE_NOSIGNALS bit looks dangerous to me - you can this way easily produce unkillable processes: Block in an ioctl with this bit set, and a bug preventing the wakeup, and you won't get rid of this process anymore. The three *LOCK bits are exclusive since there is only one pointer. I guess the retdata value us irrelevant for a timeout or an interrupt by a signal (return values ERROR_TIMEOUT and ERROR_INTERRUPT).