Comparison: ChainLocker vs. Heirarchical Mutexes

Posted in programming on March 8th, 2013 by Samuel Kenyon

In “Concurrent Programming with Chain Locking,” Gigi Sayfan presents a C# class demonstrating chain locked operations on a hierarchical data structure. This reminded me of lock hierarchies described by Anthony Williams in the book C++ Concurrency in Action.

To take a step back for a moment, the overall goal is to create multithreaded code which doesn’t cause deadlocks, race conditions, etc.  Although it may seem like a confusion of metaphors, lock hierarchies are a type of hand-over-hand locking, which is basically defined lock ordering. I think it would be fair to call a “chain” a particular path of locking through a hierarchy. Defining lock ordering is what you do if you can’t do the better idea, which is to acquire two of more locks in a single operation, for instance with the C++11 std::lock() function.

As Herb Sutter pointed out in his article “Use Lock Hierarchies to Avoid Deadlock,” you may already have layers in your application (or at least the data in a certain context). This can be taken advantage of when making the software concurrency-friendly. The general idea is that a layer does not access code in layers above it. For mutexes, this means that a layer cannot lock a mutex if it already holds a mutex from a lower layer.

Read more »

Tags: , , ,

The Timeless Way of Building Software, Part 1: User Experience and Flow

Posted in interaction design on May 31st, 2012 by Samuel Kenyon

The Timeless Way of Building by Christopher Alexander [1] was exciting. As I read it, I kept making parallels between building/town design and software design.

Architecture

We’re not talking any kind of architecture here. The whole point of the book is to explain a theory of “living” buildings. They are designed and developed in a way that is more like nature in many ways—iterative, embracing change, flexibility, and repair.

Design is recognized not as the act of some person making a blueprint—it’s a process that’s tied into construction itself. Alexander’s method is to use a language of patterns to generate an architecture that is appropriate for its context. It will be unique, yet share many patterns with other human-used architectures.

This architecture theory includes a concept of the Quality Without a Name. And this is achieved in buildings/towns in a way that is more organic than the popular ways (of course there are exceptions and partially “living” modern architectures).

User Experience

Humans are involved in every step. Although patterns are shared, each building has its own appropriate language which uses only certain patterns and puts them in a particular order. The entire design and building process serves human nature in general, and specifically how humans will use this particular building and site. Is that starting to stir up notions of usability or user-centered design in your mind?

Read more »

Tags: , , , , ,

Architecting Emotional Robots

Posted in artificial intelligence, robotics on April 7th, 2011 by Samuel Kenyon

Creating a robot with emotions is a software development problem.

How does the zebra feel right now?

Emotion is a matter of cognitive architecture.  It is part of the information system of the mind.  Recreating “emotions” really means recreating a type of mind that uses internal mechanisms similar to our minds.  Making an emotional machine requires the proper design and implementation and deployment.

The reason I added “deployment” in there is because environment is quite important.  The mind is a system that interacts with other entities—there is an information flow.  The level of externalism required affects how situated and/or embodied an artificial agent has to be.  That is where robots come in.  However, a robot and its world can be simulated.

What Do I Mean by Architecture?

The metaphor of architecture lets us think of the mind as a building.  But really I mean a large building that was built from millions of interlocking parts and took months or years to design.  And as with buildings, a mind is not just designed and built—it also has to survive the real world.

The metaphor breaks down a bit when you consider how natural minds emerge from ever-changing, growing (or shrinking), adaptable, flexible bags of meat.  However, in their own slow way buildings do change via maintenance and new additions, and they are in fact flexible and movable so as to survive wind and earthquakes.

Of equal or greater importance, I also think of architecture here in its software engineering usage [1]:

Architecture is the fundamental organization of a system embodied in its components, their relationships to each other, and to the environment, and the principles guiding its design and evolution.

Why Do We Need an Entire Architecture?

One might think that a programmer could just add in some emotion—make a few calls to the emotion function, or tack on a loosely coupled Emotion module.  But based on the best theories so far from researchers, emotions are actually many things going in the mind.  And they are all inherent in the system and intertwined with evolutionarily old parts.  In other words, if you ripped out all the stuff related to emotions, you wouldn’t have much left.  In future posts I will go into the details of potential architectures and why there are certain dependencies.

References:
[1] IEEE Computer Society, IEEE Recommended Practice for Architectural Description of Software-Intensive Systems: IEEE Std 1472000. 2000. via P. Eeles, “What is a software architecture?”

Image credits:

1. safari-partners
2. Marko Ljubez

Tags: , , , , , ,

Daniel Dennett’s Super-Snopes and the Future of Religion

Posted in philosophy on October 12th, 2010 by Samuel Kenyon

“We’re all alone, no chaperone”
—Cole Porter

Despite his resemblance to Santa Claus, Daniel Dennett wants to disillusion the believers.  If we’re all adults, why can’t we reveal the truth that God(s), like Santa, are childish fantasies?

Earlier tonight I attended Dennett’s talk “What should replace religion?” at Tufts University, which was kindly hosted by the Tufts’ Freethought Society as part of their Freethought Week.

Atheist groups will have to compete with religion in the realm of social activities such as church services.  People won’t leave churches if they don’t have something else to give them the excitement, the music, the ecstasy, the group affiliation, the team building, the moral community, etc. that churches provide.  Many churches already contain atheists who go for all the other stuff besides the doctrine.  In fact, some of the preachers themselves do not believe the doctrine.

Daniel Dennett

Daniel Dennett @ Tufts, 11 Oct 2010

I won’t go over the entire talk, but I’d like to talk about the truth segment.  Dennett pointed out the various citizen science (although he didn’t use the term citizen science) projects going on, in which random people voluntarily collect or analyze data, such as for bird watching and galaxy classification and report that to central repositories.  But certain other data collection activities have gone down—the mundane types of things such as goings-on in a town.  Town newspapers are dying, and nobody is there to take notes in local affairs (such as education, politics, etc.).  And this lost data might be important, because it is oversight.

The Internet has democratized evidence gathering while also promoting the abuse of misinformation.  So, Dennett proposes, some organizations could start projects as preservers of truth—or perhaps a church replacement could convert lovers of God into lovers of truth.  But it wouldn’t be unconditional love of truth.  The privacy of your own thoughts, for instance, may contain truthful information, but it doesn’t necessarily have to become public.  A scientific (in a broad sense of the word) organization that loves truth would compete with religion’s typically “imperfect” handling of truth.

A serious project of truth preservation could become a sort of Super Snopes.  Snopes is the famous website which debunks and/or proves true various urban legends and the like.  When you get one of those emails such as certain bananas will eat your flesh, check it out on Snopes first before continuing the hoax chain.  Dennett doesn’t define Super Snopes in detail, just that this is a kind of project that would be like Snopes or Wikipedia on an even more massive scale.  And there could be similar or overlapping projects that operate on local scales—perhaps reinstating the town/neighborhood oversight that is now missing.

Of course, something this vague has a chance of happening in the future.  But how it happens could be, as usual, an imperfect evolution from what we have now.  Hopefully secular groups, as Dennett makes the call for, will try to architect and create these projects as soon as possible.

I speculate that the projects that end up working in the future as far as truth preservation will make use of software agents (autonomous programs).  For instance, if people are not interested in taking notes on every little issue in your town/city, especially the mundane ones, then a computer can do that.

Of course, one person’s boring task is another’s hobby.  Some people enjoy collecting the data that they contribute to a central database.  But some will be able to use software agents to act as their minions—the citizen truth gatherer becomes a node, in which they are a small local central repository, which then sends data to the next biggest node, and so on.

The truth needs to be available to people whenever they want.  So the other major part of the technical aspect will be the interfaces and filters that allow humans to digest information, and to choose what streams to digest.  Of course, various web technologies have been increasing this capability (of filtering and choosing streams) for the entire life of the Internet.

Here is my question: could a (or perhaps several) Super Snopes ever evolve beyond truth preservation into actual civilization preservation, for instance like Asimov’s fictional Foundations?

(Cross-posted with Science 2.0.)

Tags: , , , , , , , ,