{"id":23513,"date":"2008-02-08T10:00:00","date_gmt":"2008-02-08T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/02\/08\/why-couldnt-you-have-more-than-one-instance-of-a-16-bit-multi-ds-program\/"},"modified":"2008-02-08T10:00:00","modified_gmt":"2008-02-08T10:00:00","slug":"why-couldnt-you-have-more-than-one-instance-of-a-16-bit-multi-ds-program","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080208-00\/?p=23513","title":{"rendered":"Why couldn&#039;t you have more than one instance of a 16-bit multi-DS program?"},"content":{"rendered":"<p>Recall that the <code>HINSTANCE<\/code> identified a set of variables. This causes a bit of a problem if your program has multiple data segments; in other words, multiple sets of variables. In such a program, the code would load the data segment of whatever variable it needed each time it needed to access a variable from a different segment.\n This was no problem at all for a DLL, since 16-bit DLLs were single-instance. Go ahead, load your selectors whenever you want. Since there&#8217;s only one copy of each data segment, you can just use them in your code and let the loader fix them up. No matter which processes calls your DLL, you&#8217;re still good.\n But if you are doing this in a program, you run into trouble once the user runs a second copy of the program. All you get is an <code>HINSTANCE<\/code> to pass to <code>MakeProcInstance<\/code> (or to infer from your stack selector). In other words, you get one set of variables. If your program uses multiple sets of variables, you don&#8217;t have a way to access those other variables, and the operating system has no way of telling you where they are.\n Now, a sufficiently clever compiler could work around this failure of mathematics. It could store the selectors of the extra data segments into the data segment specified by the <code>HINSTANCE<\/code>. When the program needed to access a variable from another data segment, it could access them by loading the appropriate selector from the stack segment register (since SS == DS). I don&#8217;t know whether anybody actually bothered to write a compiler that did this.<\/p>\n<p> Not that writing one today will win you any accolades since nobody writes 16-bit Windows programs any more. It&#8217;s one of those things that may have been a neat idea back in its day but today will just get you quizzical looks. Think of it as the computer version of inventing a higher-capacity eight-track cartridge. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recall that the HINSTANCE identified a set of variables. This causes a bit of a problem if your program has multiple data segments; in other words, multiple sets of variables. In such a program, the code would load the data segment of whatever variable it needed each time it needed to access a variable from [&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":[2],"class_list":["post-23513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Recall that the HINSTANCE identified a set of variables. This causes a bit of a problem if your program has multiple data segments; in other words, multiple sets of variables. In such a program, the code would load the data segment of whatever variable it needed each time it needed to access a variable from [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/23513","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=23513"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/23513\/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=23513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=23513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=23513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}