Friday, April 18, 2008, 07:44 AM - Design concepts
Over the last few days I have been doing some reading and have come across articles talking about the goodness of Windows Vista and Windows Server 2008. Its not about the 100 reasons why Vista is good. I came across some reasons why Vista would be good from a software developer point of view. Its very difficult to get a list of all the new C++ new features in Vista. Here is a list of some of the items I could gather and most of them are related to interprocess communication, security and threading (coz thats what I am currently working on).
Conditional variable: A condition variable is typically used by a thread to make itself wait until an expression involving shared data attains a particular state. They are also called Monitor objects by many authors. In Linux, this is supported by “pthread_cond_t”. See man pthread_cond_init. See this article from Microsoft to understand Conditional Variables in Vista. See this API page for an example and the exact APIs.
Reader/Writer Locks: Imagine you have N threads and a critical data that they use. If of these N threads, it generally happens that only a few would be updating the data and the rest would just be reading the data. Most programmers would simple use a critical section around both read and write operations on this critical data. The truth however is that, if there is currently no write operation on the critical data, then all the readers CAN have access to the critical section simultaneously. This increases performance. Windows Vista introduces native support of this concept via Reader/Writer Locks. See this MSDN page for the exact API. A Unix implementation exists as rwlock_t. See man rwlock_init .
SetProcessDEPPolicy Function: This changes data execution prevention (DEP) and DEP-ATL thunk emulation settings for a 32-bit process. What the hell is this? Lets first do a quick revision on the layout of a program(an .EXE file). The point to revise is that code segments and data segments are two separate things in the memory at run time. Most buffer-overrun attacks are done by overriding data with some malicious code. Now if the CPU was designed never to execute instructions which lie in the data section, then these nasty buffer overrun attacks will be stopped. This capability is supported by the NX feature in the CPU. The good news is that almost every CPU now a days supports NX capability. You can link your C++ program with the /NXCompat linker option to enable this for your executable. Vista adds an API also which you can call in your program to do this. Read this MSDN page for more.
Randomization of the heap: There is something called ASLR (Address Space Layout Randomization), meaning that the OS randomizes the address space of your program so that it become difficult to predict location of vulnerabilities in a running image. In Vista, this randomization is extended to your program heap also.
Thread Pool API: Vista introduces Thread Pool API for C/C++ programmers. I have been using Boost thread pool(actually an extension of the Boost thread library) which is a cross-platform implementation. Just by looking at the Microsoft Thread Pool API, it appears that we need quite a bit of reading/understanding than what is traditionally considered enough to understand thread pool.
Happy Programming.//




( 3 / 37 )


Calendar




