Fork And Run: The Definitive Guide To Getting Started With Multiprocessing

Since the early 2000s, the CPU industry has shifted from raw clock speed to core counts. Pat Gelsinger famously took the stage in 2002 and gave the talk the industry needed, stating processors needed specialty silicon or multiple cores to reduce power requirements and spread heat. A few years later, the Core series was introduced with two or four-core configurations to compete with the AMD Athlon 64 x2.

Nowadays, we’re seeing heterogeneous chip designs with big and little cores, chiplets, and other crazy fabrication techniques that are fundamentally the same concept: spread the thermal load across multiple pieces of silicon. This writer is willing to put good money into betting that you’ll see consumer desktop machines with 32 physical cores in less than five years. It might be hard to believe, but a 2013 Intel Haswell i7 came with just four cores compared to the twenty you’ll get in an i7 today. Even an ESP32 has two cores with support in FreeRTOS for pinning tasks to different cores. With so many cores, how to even write software for that? What’s the difference between processes and threads? How does this all work in straight vanilla C98?

Continue reading “Fork And Run: The Definitive Guide To Getting Started With Multiprocessing”

Thread Carefully: An Introduction To Concurrent Python

The ability to execute code in parallel is crucial in a wide variety of scenarios. Concurrent programming is a key asset for web servers, producer/consumer models, batch number-crunching and pretty much any time an application is bottlenecked by a resource.

It’s sadly the case that writing quality concurrent code can be a real headache, but this article aims to demonstrate how easy it is to get started writing threaded programs in Python. Due to the large number of modules available in the standard library which are there to help out with this kind of thing, it’s often the case that simple concurrent tasks are surprisingly quick to implement.

We’ll walk through the difference between threads and processes in a Python context, before reviewing some of the different approaches you can take and what they’re best suited for.

Continue reading “Thread Carefully: An Introduction To Concurrent Python”

Chair Dances Like No One Is Watching

Although it might be more accurate to say that this chair dances because no one is watching, the result is still a clever project that [Igor], a maker-in-residence at the National Museum of Decorative Arts and Design in Norway, created recently. Blurring the lines between art, hack, and the ghosts from Super Mario, this chair uses an impressive array of features to “dance”, but only if no one is looking at it.

In order to get the chair to appear to dance, [Igor] added servo motors in all four legs to allow them to bend. A small non-moving dowel was placed on the inside of the leg to keep the chair from falling over during all of the action. It’s small enough that it’s not immediately noticeable from a distance, which helps maintain the illusion of a dancing chair.

From there, a Raspberry Pi 3 serves as the control center for the chair. It’s programmed in Python and runs OpenCV for face detection and uses pigpio for controlling the leg servos. There’s also a web interface for watching the camera’s output and viewing its facial recognition abilities. The web interface also allows a user to debug the program. [Igor]’s chair can process up to 3 frames per second at 800×600 pixels.

Be sure to check out the video after the break to see the chair in action. It’s an interesting piece of art, and if those dowels can support the weight of a person it would be a great addition to any home as well. If it’s not enough chair for you, though, there are some other more dangerous options out there.

Continue reading “Chair Dances Like No One Is Watching”