{"id":9443,"date":"2011-10-07T07:00:00","date_gmt":"2011-10-07T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/10\/07\/during-process-termination-slim-readerwriter-locks-are-now-also-electrified\/"},"modified":"2011-10-07T07:00:00","modified_gmt":"2011-10-07T07:00:00","slug":"during-process-termination-slim-readerwriter-locks-are-now-also-electrified","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20111007-00\/?p=9443","title":{"rendered":"During process termination, slim reader\/writer locks are now also electrified"},"content":{"rendered":"<p>Some time ago I mentioned that <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/01\/22\/9951750.aspx\"> during process termination, the gates are now electrified<\/a>: If you attempt to enter a critical section that is owned by a thread that was terminated by an earlier phase of process termination, the entire process is forcibly terminated.\n Windows Vista introduced a new lightweight synchronization pseudo-object known as the <a href=\"http:\/\/msdn.microsoft.com\/library\/aa904937.aspx\"> slim reader\/writer lock<\/a>. And if you tried to enter a slim reader\/writer lock during process termination and found yourself waiting for the current owner to release it, <a href=\"http:\/\/www.bluebytesoftware.com\/blog\/2006\/11\/19\/VistaSRWLockAcquiresDuringShutdown.aspx\"> you ended up waiting forever<\/a> since the current owner was terminated by an earlier phase of process termination. The sentence &#8220;<a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2007\/05\/03\/2383346.aspx\">As for the home-grown stuff, well, you&#8217;re on your own<\/a>&#8221; applies here. Even though the slim reader\/writer lock functions are exported from <code>kernel32.dll<\/code>, they don&#8217;t have any special kernel powers with respect to process termination. From the standpoint of process termination, they may as well be some home-grown synchronization primitive.<\/p>\n<p> In Windows&nbsp;7, the kernel folks decided to bring slim reader\/writer locks into the fold of <i>objects which are electrified during process termination<\/i>. Starting in Windows&nbsp;7, if you attempt to acquire a slim reader\/writer lock during process termination, and the lock cannot be immediately acquired, then the process is forcibly terminated. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago I mentioned that during process termination, the gates are now electrified: If you attempt to enter a critical section that is owned by a thread that was terminated by an earlier phase of process termination, the entire process is forcibly terminated. Windows Vista introduced a new lightweight synchronization pseudo-object known as the [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-9443","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Some time ago I mentioned that during process termination, the gates are now electrified: If you attempt to enter a critical section that is owned by a thread that was terminated by an earlier phase of process termination, the entire process is forcibly terminated. Windows Vista introduced a new lightweight synchronization pseudo-object known as the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=9443"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9443\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=9443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=9443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=9443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}