Linux Fu: An Odd Use For Fork()

If you are a Star Trek fan, you’ll probably remember the phrase “You have to learn why things work on a starship.” The truth is, in most episodes, knowing how to override another ship’s console or make gunpowder didn’t come in very handy, but boy when it did, it really saved the day. Linux is a lot like that. There are a few things you probably don’t need to know very often, but when you do need to know, it makes a huge difference. In this particular post, I want to look at an odd use of the fork system call. For many purposes, you’ll never need to know this particular irregular use. But when you need it, you are really going to need it.

This is actually based on an old client of mine who used Unix to run a massive and very critical report every day.  The report had a lot of math since they were trying to optimize something and then generate a lot of reports. In those days, the output of the report was on old green-bar paper on a line printer. The problem was that the report took something like 14 hours to run including the printouts. If someone discovered something wrong, there was no time to run the report again because the next day’s report would have to start before the second run would finish.

The client had a bunch of Windows programmers and — at that time — there wasn’t anything really analogous to a real fork call in Windows. I looked at the code and realized that probably most of the code was spending time waiting to print the output. The computer had multiple CPUs and there were multiple printers, but that one program was hanging on the one printer. There was a lot of data, so writing it to a database and then running different reports against it wasn’t a great option. The answer was to use the power of fork. With a change in the code that took less than 30 minutes, the report ran in five hours. They were very pleased.

So how did I do it? The answer lies in how fork works. Just about every time you see a fork, you see some sort of exec call to start a new program. So if you think about fork at all, you probably think it is part of how you start a new program and, most of the time, that’s true. Continue reading “Linux Fu: An Odd Use For Fork()”

Modular Laptop Maker Provides Mainboard Documentation For Non-Laptop Projects

If you’ve been following the latest advancements in computing for a while, you already know that there’s a big problem with laptops: When they’re no longer useful as a daily driver, it can be a struggle to find a good use for all its parts. Everything is proprietary, and serious amounts of reverse engineering are required if you decide to forge ahead. This is where Framework, a laptop company building modular laptops comes in. They’ve made it clear that when you upgrade your Framework laptop with a new mainboard they want you to be able to continue to use the old mainboard outside of the laptop.

When it's done powering your laptop, use it for a cyberdeck?
When it’s done powering your laptop, use it for a cyberdeck?

To that end, Framework have provided 2D mechanical drawings of their mainboard and 3D printable cases that can of course be modified as needed. “But what about peripherals?” you might ask. Framework has provided pinouts for all of the connectors on the board along with information on which connectors to use to interface with them. No reverse engineering needed!

While it’s possible to buy a mainboard now and use it, their stated goal is to help people make use of used mainboards leftover from upgrades down the line. With just a stick of memory and a USB-C power adapter, the board will spring to life and even has i2c and USB immediately available.

What would you do with a powerful Intel i5-1135G7 mainboard? Framework wants to know, and to that end, they are actually giving away 100 mainboards to makers and developers. Mind you this is a program created and ran by Framework — and is not associated in any way Hackaday or our overlords at Supplyframe.

If you’ve read this far and still don’t know what the Framework laptop is, go check out this introduction by our own [Jenny List].

Hoverbike Turns Hoverboard Into Ebike

Hoverboards were a popular trend with the youths and in-crowd a few years ago, and now that the fad has largely died out there are plenty of them sitting unused in closets and basements around the world. That only means opportunities to put the parts from these unique transportation devices into other builds. A more practical method of transportation is a bicycle, and this build scavenges most of the parts from a hoverboard to turn a regular bicycle into a zippy ebike.

This bike build starts with a mountain bike frame and the parts from the hoverboard are added to it piece by piece. The two motors are mounted to the frame and drive the front chain ring of the bike, allowing it to still take advantage of the bike’s geared drivetrain. Battery packs from two hoverboards were combined into a single battery which give the bike a modest 6-10 km of range depending on use. But the real gem of this build is taking the gyroscopic controller board from the hoverboards and converting it, with the help of an Arduino Due, to an ebike controller.

Eventually a battery pack will be added to give the bike a more comfortable range, but for now we appreciate the ingenuity that it took to adapt the controller from the hoverboard into an ebike controller complete with throttle and pedal assist. For other household objects turned into ebikes, be sure to check out one of our favorites based on a washing machine motor: the Spin Cycle.