Code Bits & Electronics

This Blog is primarily about programming and how to write faster code, also I will occasionally be posting schematics for the electronics projects I have been working on.

Blog Feed

Implementing a Spinlock

A spinlock is a system by which exclusive access to a resource is provided to a thread. In the case that the current thread requires access to a resource that is currently being used by a different thread, a spinlock will intentionally waste CPU cycles waiting for the resource to become available. But why useContinue reading “Implementing a Spinlock”

Efficient Reverse Strpbrk

I recently found myself needing to find the last occurrence of any listed character within a string. The simple but na├»ve approach is to repeatedly search the entire string for each character in the list and update the last position variable as appropriate: This will work but is sub-optimal, so lets improve on it: TheContinue reading “Efficient Reverse Strpbrk”


Follow My Blog

Get new content delivered directly to your inbox.

Create your website with WordPress.com
Get started