--- src/sys/kern/kern_synch.c 2007/12/06 15:03:25 1.88 +++ src/sys/kern/kern_synch.c 2008/03/05 12:44:43 1.89 @@ -61,6 +61,7 @@ #include #include +#include #include #include @@ -613,6 +614,30 @@ msleep(void *ident, struct spinlock *spi } /* + * Interlocked serializer sleep. An exclusively held serializer must + * be passed to serialize_sleep(). The function will atomically release + * the serializer and tsleep on the ident, then reacquire the serializer + * and return. + */ +int +serialize_sleep(void *ident, struct lwkt_serialize *slz, int flags, + const char *wmesg, int timo) +{ + int ret; + + ASSERT_SERIALIZED(slz); + + crit_enter(); + tsleep_interlock(ident); + lwkt_serialize_exit(slz); + ret = tsleep(ident, flags, wmesg, timo); + lwkt_serialize_enter(slz); + crit_exit(); + + return ret; +} + +/* * Directly block on the LWKT thread by descheduling it. This * is much faster then tsleep(), but the only legal way to wake * us up is to directly schedule the thread.