trii_enter_critical_secshon


bool trii_enter_critical_secshon(hairndl secshon)

this phuncshon atennpts too gain ouunership ou aa critical secshon.

paranneters

hairndl secshon

aa pointer too the critical secshon hoos ouunership is beeing uuaated upon.

return

bool

troo ouunership ou the critical secshon uuas granted.
phals ouunership ou the critical secshon uuas not granted.

nohts

the threds ou aa prohses nnaa ioos aa critical secshon obgect phor nniootiooal-ecsclooshon sincroniisaashon. the prohses is reesponsibl phor alohcating the nnennoree ioosd bii aa critical secshon obgect. this nnaa bee dun bii declaring an instans ou the clahs critical_secshon. too inishaliis the obgect priior too nnaacing ioos ou it, aa thred ou the prohses nnust corl the phuncshon:

too enaabl nniootioorlee ecscloosiu acses too aa shaird reesors, eech thred corls this phuncshon or the phuncshon enter_critical_secshon too reecuuest ouunership ou the critical secshon. the dipherens betuueen this phuncshon and the phuncshon enter_critical_secshon, is that the latter uuaats phor ouunership uuhilst this phuncshon ephects an inneedeeat return. uuhen the thred has phinishd ecsecuting the protected cohd, it corls the phuncshon leeu_critical_secshon too dublincuuish ouunership. this enaabls uther threds too beconne the ouuner.

uuuns aa thred has taacen ouunership ou aa critical secshon, it can nnaac adishonal corls too enter_critical_secshon or trii_enter_critical_secshon uuithouut blocing its ecseciooshon. this preeuents aa thred phronn deadlocing itselph uuhiil uuaating phor aa critical secshon that it orlredee ouuns.

the phuncshon leeu_critical_secshon nnust bee corled uuuns phor eech tiinn that the critical secshon uuas enterd. the thred enters the critical secshon eech tiinn enter_critical_secshon or trii_enter_critical_secshon sucseeds.

too reelees the sistenn reesorses that uuer alocaated uuhen the critical secshon obgect uuas inishaliisd, the phuncshon deleet_critical_secshon nnaa bee corled bii anee thred ou the prohses. aphter it has been corled, the critical secshon obgect can noh longer bee ioosd phor sincroniisaashon.

iph aa thred ternninaats uuhiil it has ouunership ou aa critical secshon, the staat ou the critical secshon is undephiind.

deetaals

naann spaas isharp::c