{"id":96585,"date":"2017-07-12T07:00:00","date_gmt":"2017-07-12T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=96585"},"modified":"2019-03-13T01:14:02","modified_gmt":"2019-03-13T08:14:02","slug":"20170712-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20170712-00\/?p=96585","title":{"rendered":"Why is the maximum number of TLS slots 1088? What a strange number."},"content":{"rendered":"<p>Commenter Max noted that the maximum number of TLS slots is 1088 and wondered <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20160610-00\/?p=93645#comment-1252095\">why such a strange number<\/a>. &#8220;I mean, it does not look like a perfect number in terms of 2-based numeric system.&#8221; <\/p>\n<p>It looks a little better in base 2. The value is <code>10001000000<\/code> which breaks down as 1024 + 64. <\/p>\n<p>When TLS was first introduced, the number of available TLS slots was 64, and those slots were pre-allocated as part of the thread control block. Over time, 64 slots turn out not to be enough, so the kernel team modified the code to allocate a page of data per thread once the 65th request for a TLS slot was made. A page of data is 4KB, which has enough room for 1024 32-bit values. That&#8217;s why the total is 1088. It&#8217;s the original 64 slots, plus an addition 1024 slots. <\/p>\n<p>Note that the statement that &#8220;the maximum number of slots is 1088&#8221; is a statement of current implementation, not a contractual obligation. The contractual obligation is that there will always be at least <code>TLS_<\/code><code>MINIMUM_<\/code><code>AVAILABLE<\/code> slots available. Any more than that is just gravy. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s a little less strange in binary.<\/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-96585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It&#8217;s a little less strange in binary.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/96585","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=96585"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/96585\/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=96585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=96585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=96585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}