ERESOURCE加锁函数

最常用的加锁函数只有两个:

  • ExAcquireResourceExclusiveLite:试图获取排它锁
  • ExAcquireResourceSharedLite:试图获取共享锁

除此之外,针对共享锁的获取,还有另外两个函数:

  • ExAcquireSharedStarveExclusive:可以早于等待中的排它请求者
  • ExAcquireSharedWaitForExclusive:不能早于排它的请求者

二者都是试图获取共享锁,和ExAcquireResourceSharedLite只是有些微的小差别。但这两个函数使用的并不多,只限于少见的特殊情况:

ERESOURCE本身是可以重入的,如果当前线程已经获得此锁的话,若再次试图获取,ExAcquireResourceSharedLite将会直接准予此请求,但ExAcquireSharedWaitForExclusive则不会,一定要等到此锁等待列表中所有的排它锁的请求者完成之后才会准予当前调用者。当然如果当前线程之前所获得的ERESOURCE锁是排它锁的话,将会直接准予通行,不然会导致死锁发生。

ExAcquireSharedStarveExclusiveExAcquireResourceSharedLite的差别只在一点:若已是共享锁状态,ExAcquireSharedStarveExclusive将忽略排它锁等待列表中的所有请求者,直接准予当前线程,以尽可能的减少当前线程的等待时间。

3 条评论

  1. Anyone else notice that weird glitch on the bamboo platforms? I keep getting stuck mid-jump and it’s kinda sus. Otherwise, the mechanics are smooth as butter for a mobile game.

  2. Just tried BuildNow GG for the first time and it’s an absolute banger! The Sprunki music slaps so hard I’ve been vibing to it for hours. Can’t wait to see what the devs add next!

  3. Casual player here, and BuildNow GG is my go-to chill game. Love hopping in after work to build random stuff. The community’s pretty friendly too, which is a nice change from some toxic lobbies out there. Keep up the good work!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注