<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>---
Q:/projinf2/trunk/hw/mlx4/kernel/inc/shutter.h (revision 3954)<BR>+++
Q:/projinf2/trunk/hw/mlx4/kernel/inc/shutter.h (revision 3955)<BR>@@ -48,14
+48,29 @@<BR> KeInitializeEvent( &p_shutter->event,
SynchronizationEvent, FALSE );<BR> }<BR> <BR>-// if RC > 0, one can
proceed<BR>-static inline int shutter_use(shutter_t * p_shutter)<BR>+<BR>+static
inline void shutter_sub(shutter_t * p_shutter,long
Val)<BR> {<BR>- long res = InterlockedIncrement(
&p_shutter->cnt ); <BR>+ long res =
0;<BR>+ ASSERT(Val < 0);<BR>+ res =
InterlockedExchangeAdd( &p_shutter->cnt,Val );<BR>+ if ((res+Val) ==
-MAX_OPERATIONS)<BR>+ KeSetEvent( &p_shutter->event, 0, FALSE
);<BR>+}<BR>+<BR>+// if RC == true, one can proceed<BR>+static inline BOOLEAN
shutter_add(shutter_t * p_shutter,long Val)<BR>+{<BR>+ long
res = 0;<BR>+ ASSERT(Val > 0);<BR>+ res =
InterlockedExchangeAdd(&p_shutter->cnt,Val); <BR> ASSERT(res
<= MAX_OPERATIONS);<BR>- if (res <= 0 )
<BR>- InterlockedDecrement( &p_shutter->cnt ); // The object
is in shutdown<BR>- return res;<BR>+ if (res < 0
)<BR>+ {
<BR>+ shutter_sub(p_shutter, -Val);<BR>+ return
FALSE;<BR>+ }<BR>+ return TRUE;<BR> }<BR> <BR> static
inline void shutter_loose(shutter_t * p_shutter)<BR>@@ -65,14 +80,38
@@<BR> KeSetEvent( &p_shutter->event, 0, FALSE
);<BR> }<BR> <BR>+// if RC > 0, one can proceed<BR>+static inline
int shutter_use(shutter_t * p_shutter)<BR>+{<BR>+ long res =
InterlockedIncrement( &p_shutter->cnt ); <BR>+ ASSERT(res <=
MAX_OPERATIONS);<BR>+ if (res <= 0 ) <BR>+ shutter_loose(
p_shutter ); // The object is in shutdown<BR>+ return
res;<BR>+}<BR>+<BR>+<BR> static inline void shutter_shut(shutter_t *
p_shutter)<BR> {<BR>- long res;<BR>+
//<BR>+ // ASSERT not calling shu
twice.<BR>+ //<BR>+ ASSERT(p_shutter->cnt
- MAX_OPERATIONS >= (-MAX_OPERATIONS));<BR>+
<BR> // Mark the counter as locked<BR>- res =
InterlockedExchangeAdd(&p_shutter->cnt, -MAX_OPERATIONS);<BR>+ long
res = InterlockedExchangeAdd(&p_shutter->cnt,
-MAX_OPERATIONS);<BR> ASSERT(res >= 0);<BR> if (res)
<BR> // We are now waiting for the object to reach
-MAX_OPERATIONS<BR> KeWaitForSingleObject(
&p_shutter->event, Executive, KernelMode, FALSE, NULL
);<BR> }<BR> <BR>+static inline void shutter_alive(shutter_t *
p_shutter)<BR>+{<BR>+ ASSERT(p_shutter->cnt ==
-MAX_OPERATIONS);<BR>+ // Mark the counter as locked<BR>+ long res =
InterlockedExchangeAdd(&p_shutter->cnt,
MAX_OPERATIONS);<BR>+ ASSERT(res <
0);<BR>+}<BR>+<BR>+<BR></FONT></DIV></BODY></HTML>