WaitForMultipleObjects and WIN32 events for Linux/OS X/*nix and Read-Write Locks for Windows

As every programmer worth his salt knows, synchronization primitives form the very building blocks of multithreaded programming. Without them, the world as we know it would cease to exist and chaos would reign free and unchecked.

All joking aside, synchronization objects such as mutexes and semaphores are essential to safe multithreading and are found on just about any platform under the sun. Mutexes and semaphores alike have one purpose: to keep different threads from messing around with bits and bytes at the same time another thread is, keeping your code free of segfaults and memory access violations alike. But that’s about where the similarities between the synchronization primitives on different platforms end.

POSIX-compliant operating systems with pthreads offer additional really neat synchronization primitives not found on Windows, such as condition variables and read-write locks (the latter is now available on Windows Vista+). And Windows programmers have at their disposal automatic and manual reset events, which make designing certain types of multithreaded software incredibly easy, abstracting away much of the hard-core synchronization logic that lies beneath the hood.

Continue reading

My Thoughts on Sutter’s “C++ and Beyond 2011”

Around a month ago, Herb Sutter gave a talk on why C++ is once more gaining relevance in the world of programming, and how after a decade of neglect and abandonment, it is set to pave the way into the future. I downloaded it a while ago and finally had a chance to watch it last night; the talk itself is most-excellent and is around 40 minutes long, you can stream it online or download it in a higher-resolution format on Channel 9. Or click below to watch:

As someone that’s been using both C/C++ and .NET extensively over the past years, I found there was one very important point that Sutter glanced on, danced around, and did everything short of actually naming in his talk and it’s that if you’re doing anything remotely intricate or complicated, leaky abstractions in managed languages will bite you in the ass, and end up lowering your productivity, some times (and if what you’re working on is truly complicated, often times) to a point where you’d have been more productive using C or C++ in the first place.

The concept of leaky abstractions isn’t anything new and I’m hardly the first to point out how it can turn a knight in shining armor into a harbinger of doom and destruction. It’s the number one problem fundamentally present in almost any framework, but even more so in managed languages where the framework is all you have, and you’re not allowed to side-step it and build your own foundations to work with (p/invoke and interop aside). But lately it’s becoming more and more of a problem as the “push” for innovation that Sutter speaks of has become a fundamental requirement in just about all corners of the industry.

Continue reading

Intel C++ Compiler 12??

Microsoft Visual Studio 2010 has been officially released for 3 months now (to the day), and to be pedantic, it has also been available in beta form since October 2008. Its bugs not withstanding, Visual Studio 2010 been a pretty successful hit. Besides the huge improvements to the .NET language and platform, big on the list of features for C++ developers is basic support for C++0x (the next standard version of C++, with lots of new & revolutionary features) and plenty of IDE enhancements. Intel’s C++ Compiler is the industry-standard with regards to performance and optimizations, still doesn’t support Visual Studio 2010 or C++0x.

As numerous postings on the Intel forums indicate, a plethora of users are in pressing need of an update to the Intel C++ Compiler. Questions on the matter are brushed-off, with short and rather-useless replies such as:

“This question has been discussed several times recently. The first such integration would come in a beta version of icc 12.0, which hasn’t yet been announced.”

Continue reading

Shipping Seven is a Fraud.

A blog titled Shipping Seven has gotten a lot of traffic recently for their article about Windows 7 and the MinWin kernel – namely, how they’re actually one and the same. The argument offered by “Soma” is that Windows Vista’s kernel (which is what Windows 7 will be built on) is MinWin ad that it’s already on every Vista desktop out there.

Whether or not MinWin is the very same kernel that went into Vista or not is officially unknown at the moment; but what we do know is that Shipping Seven is either one huge fake, or else that the Windows core programmers at Microsoft are so stupid that they don’t know the first thing about coding, kernels, operating systems and compilers.

The post at Shipping Seven is littered from beginning to end with fallacies, lies, and incorrect deductions that anyone with even the most basic coding skills would know better than to ever post, especially not when attempting to pass it off as the work of some of the more talented coders out there.

Continue reading

Programmers Should Trust Their Instincts

People are either cut out to be programmers or they’re not. How to know, what to do if you’re not, and where to go from there is a huge issue and not the subject of discussion. But one of the signs of a good programmer is good programming instincts. The right instincts can save hours of work and provide creative solutions to even the most difficult problems; and “gut feelings” in programming are not something you should ignore lightly.

One of the first thing Computer Science teachers drill into the heads of their students is that it’s important to map everything out beforehand. Design the algorithm. Draw the UML diagrams. Decide the entire flow of data and the relationships between everything before you even touch the IDE. While this is integral advice for anything above a small-complexity project, there is an exception: if you have a gut feeling, follow it.

For instance, the other day I sat down to write a simulator for a MIPS datacache, with different replacement policies. “Ideally,” the planning procedure would have involved designing the sequence diagram, a flowchart detailing the method used by the cache to determine expired entries, and generally-speaking a lot of time down the hole just visualizing what happens beforehand.

Continue reading

Want UAC-Free iReboot? You got it: iReboot 1.1 released!

Back in August of 2007, NeoSmart Technologies released iReboot 1.0 – a tiny application that sits quietly and unobtrusively in the taskbar and is used to select which OS you’d like to reboot into.

iReboot isn’t by any means a major application, but it’s gathered a pretty strong following over the months, mostly by people interested in boosting productivity (or increasing laziness) to the max. But there was one flaw in iReboot that made all the hard work we put into making it as unobtrusive and minimalistic as possible almost meaningless: if you had UAC enabled, iReboot will not run automatically at startup, no matter what you do.

This behavior comes as a result of the architecture that Microsoft used to secure Windows Vista, which doesn’t allow for applications requiring admin approval to run at startup. It doesn’t matter what your application does or if you absolutely trust it beyond the shadow of the doubt, Windows Vista simply won’t let an application that runs in elevated privileges mode to launch at startup – end of story.

Continue reading

The NeoSmart DevNet Initiative

NeoSmart Technologies is pleased to announce the logical next-step in our contributions to the tech community by the establishment of the NeoSmart DevNet project.

NeoSmart DevNet is a new effort on behalf of NST to reach out and lend a helping hand to other software developers by providing a number of tools, libraries, and frameworks that we’ve developed over the last several years to address certain commonly-encountered issues in a generic-yet-customizable manner.

Basically, DevNet is an attempt at getting software developers to spend more time on developing their applications verses worrying about the stuff that they need to get there. Unlike other developer resources on the internet, the goal of DevNet is to provide complete working subsystems and frameworks to developers, almost entirely doing away with the need for supplemental coding and code-monkey work.

For instance, the first of our DevNet projects to be released is a scriptable graphical HTTP/FTP downloader. The NeoSmart Downloader (NST Downloader) is intended to be drop-in solution for anyone looking to add the ability to download and run components from the internet to their software projects. All interfacing with the NST Downloader is done via command-line arguments, making it language-agnostic and dead-simple to use.

Continue reading

Vista SP1 Doesn’t Kill Software, Bad Coders Do

You can always trust The Register to do what it can to twist the facts into a nice, juicy headline. This time, it’s about Windows Vista SP1, and the very short list of software that’s adversely affected by its installation.

Don’t get this wrong: we’ve got our own reservations about SP1 (between performance and usability – or, more accurately, the lack thereof). But Microsoft is not to blame because certain system tools and utilities won’t run on Windows Vista SP1 when it’s released in March.

According to The Register, "Vista SP1 kills and maims security apps, utilities" and that it’s somehow Microsoft’s fault that antivirus/firewall software by BitDefender, Jiangmin, Trend Micro, and Zone Alarm no longer works on SP1 – but it seems they forgot to mention two facts:

  1. It’s bad coding habits that breaks these utilities.
  2. Thanks to pre-release builds of Vista SP1, all 5 malware-protection programs have updated versions available that are Vista SP1 compatible and shouldn’t give their users any problems come mid-March and SP1.

Continue reading

Don’t Believe The Lies: PHP Isn’t Thread-Safe Yet

If you took everything you heard for granted, you’d have been lead to believe that the official PHP distributions (from php.net) have been thread-safe since version 5.2.0.

That’s not true. Don’t fall for it. Don’t attempt to use PHP in a multi-threaded environment (mpm_worker on Apache, ISAPI on IIS, etc.), because PHP thread-safety is a myth.. nothing more than a bunch of lies, if you will.

If you look at the PHP download page, you’ll see that the pre-built binaries (in this case, Windows) are split into two: thread-safe and non-thread-safe:


The problem is, no matter which you choose, PHP isn’t thread safe. You’ll still get the same, old, dreaded “PHP has encountered an access violation at memory_address” error.

It’s not a question of server configuration so much as it is one of PHP writing bad code and pretending that’s not the case. PHP isn’t multi-threading ready and most everyone knows it… but it seems they still feel the need to pass it off as if it were, never mind the complaints and bug reports that come.

Continue reading

Microsoft’s .NET-Powered Windows Live Writer

Believe it or not, Microsoft’s Microsoft .NET LogoWindows Live Writer is important in more ways than one. To most PC users, Windows Live Writer is simply the best tool that gets the “job” done. More importantly is how “job” is defined though, because WLW does things quite well and quite thorough.

Windows Live Writer has a huge range of options and takes advantage of almost all the features and functionality available via remote blogging/XMLRPC that make it almost pointless to even enter your blog’s administration center. You can upload images and movies, set categories and keywords, specify the slug/permalink to posts, modify the post date, set passwords on posts, send trackbacks, manually create an excerpt, and even specify whether comments are or aren’t allowed on any given post – all this without leaving your desktop client.

But what most don’t know about Windows Live Writer is more what it represents than what it does: Windows Live Writer is the first full-scale consumer product to ship out of Microsoft’s camp built on the .NET Framework.

Continue reading