NSBlog
"A failure in the hot air department"
Showing entries tagged "threading". Full blog index.
Friday Q&A 2017-10-27: Locks, Thread Safety, and Swift: 2017 Edition
at 2017-10-27 11:28
Back in the dark ages of Swift 1, I wrote an article about locks and thread safety in Swift. The march of time has made it fairly obsolete, and reader Seth Willits suggested I update it for the modern age, so here it is!
Friday Q&A 2015-05-29: Concurrent Memory Deallocation in the Objective-C Runtime
at 2015-06-05 13:06
The Objective-C runtime is at the heart of much Mac and iOS code. At the heart of the runtime is the
objc_msgSend
function, and the heart of that is the method cache. Today I'm going to explore how Apple manages resizing and deallocating method cache memory in a thread safe manner without impacting performance, using a technique you probably won't find in textbooks discussing thread safety.Friday Q&A 2015-02-20: Let's Build @synchronized
at 2015-02-20 14:26
Continuing the theme of thread safety from the previous article, today I'm going to explore an implementation of Objective-C's
@synchronized
facility in the latest edition of Let's Build. I'm going to build it in Swift, although an equivalent Objective-C version would be much the same.Friday Q&A 2015-02-06: Locks, Thread Safety, and Swift
at 2015-02-06 14:23
An interesting aspect of Swift is that there's nothing in the language related to threading, and more specifically to mutexes/locks. Even Objective-C has
@synchronized
and atomic properties. Fortunately, most of the power is in the platform APIs which are easily used from Swift. Today I'm going to explore the use of those APIs and the transition from Objective-C, a topic suggested by Cameron Pulsford.Friday Q&A 2014-06-06: Secrets of dispatch_once
at 2014-06-06 13:27
Reader Paul Kim pointed out an entry on Michael Tsai's blog about making
dispatch_once
fast. While the comment in the dispatch_once
source code is fascinating and informative, it doesn't quite delve into the detail that some would like to see. Since this is one of my favorite hacks, for today's article I'm going to discuss exactly what's going on there and how it all works.Deadlocks and Lock Ordering: a Vignette
at 2012-02-13 04:26
Every once in a while, when writing threaded code, you may find yourself wanting to acquire two different locks in a critical section. Normally one should resist such perversions, but sometimes they just end up being necessary, or too tempting. Holding multiple locks at the same time immediately raises the specter of deadlock: if two threads acquire the same locks in a different order, they can end up waiting on each other forever.
Friday Q&A 2012-01-20: Fork Safety
at 2012-01-20 14:07
It's once again time to dive into bizarre programming arcana. In today's article, I want to look at the details of fork-safe code, why the restrictions are present, and why you might care, a topic suggested by Ben Mitchell.
Friday Q&A 2011-03-04: A Tour of OSAtomic
at 2011-03-04 18:24
It's time for another crazy edition of Friday Q&A. Today, Paul Kim has suggested that I give a tour of OSAtomic, OS X's built-in low-level functions for lockless thread-safe operations. Given the announcement Wednesday of the dual-core iPad 2, this was a particularly prescient suggestion on his part.
Friday Q&A 2010-12-03: Accessors, Memory Management, and Thread Safety
at 2010-12-03 16:53
It's once again time for a brand new edition of Friday Q&A. This week, I'm going to talk about accessors, and how to properly deal with memory management and thread safety when creating them, a topic suggested by Daniel Jalkut.
Friday Q&A 2009-11-13: Dangerous Cocoa Calls
at 2009-11-13 20:38
It's another Friday, and so time for another Friday Q&A. This week, Quentin Carnicelli (one of the guys who signs my paychecks) suggested that I talk about dangerous API calls in Cocoa.
Friday Q&A 2009-04-10: Multithreaded Optimization in ChemicalBurn
at 2009-04-10 17:22
Welcome to another Friday Q&A, where all the women are strong, all the men are good-looking, and all the programmers are above average. This week, Phil Holland has suggested that I dissect an interesting piece of code from one of my screensavers, so we're going to take a look at ChemicalBurn's multithreaded routing code.
Friday Q&A 2009-01-09
at 2009-01-09 21:38
Greetings one and all. I caught my mistaken writing of "2008" in this blog post title almost instantly instead of only noticing after I'd already posted it like I did last week, so the year must be coming along. Welcome to the second Friday Q&A of 2009 (and only the fourth in all human history!) where I'll be taking Ed Wynne's suggestion and talking about the various meanings and implications of thread safety as they apply to Mac OS X system frameworks.
Friday Q&A 2008-12-19
at 2008-12-20 01:28
Great response last week. This week I'm going to merge Sam McDonald's question about how I got into doing multithreaded programming and Phil Holland's idea of talking about the different sorts of parallelism available.
Late Night Cocoa
at 2008-09-05 23:31
Readers of this blog may be interested in my recent appearance on Late Night Cocoa. I discussed the fundamental principles and basic concepts behind lockless thread-safe data structures. You can access the episode here.