Wednesday, March 23, 2011

Choosing a better metaphor for Life

"Life is a game" places you at the mercy of Life.

An empowering metaphor was suggested to me by my friend and colleague Shivakalyani Ankam.

"Live is a movie, you are the director". This places you in control of Life.

Context switches and context context switches

I am modal. I work in modes and switching between modes is a context switch, hence energy draining.

Once in a while it is important to move from "pixel mode" to "big picture mode".

The problem is that I need a context switch to realize when I need to context switch!

Friday, March 11, 2011

Working styles explained using system software metaphors

Negative Work (Disruptive)
Overactive Assert: The original issue is long since fixed, but you keep disrupting the process.
Deadlock: Unclear priorities can cause things to come to a grinding halt
Timer Callback: You can only do useful work in the context of someone else making you do it.
Memory Leak: You leak resources through mismanagement, causing imbalances in the system load, eventually having it crash.
Memory Corruption: You take sides, whisper different things to different people, word messages to be ambiguous. This causes failures in random places. It is often difficult to trace the root cause to you.
Thrashing: Too many page faults decreases effectiveness
while(1) Complain(); All you can do is be angry and complain about everything. You don't offer any solution to the problem.
while(1) Oppose(); All you can do is oppose everything that's going on around you.
Zero Work (Wasted Resources)
Spin-lock: You keep spinning on a task and never get any useful work done.
Zombie Process: You are long done with your assigned work and no one cares you exist.
Signal / Exception Handler: The only work you do is in response to an emergency condition. Only when the going gets tough, you get going!
Positive Work (Better use of Resources)
Semaphore: You work through a list of N items one at a time. When N drops to zero, you go to sleep.
Thread pool + Notification queue + No Throttle: You have a queue of items that you can work through in parallel, but cannot say no, leading to a nervous breakdown.
Best Case (Best use of Resources)
Thread pool with Priority Queue, Internal Resource Limits, Fairness, No memory Leaks/Corruption: You can multi-task. You know the relative importance of tasks.You pace your work and always make forward progress. You work with maximum integrity and efficiency, with minimal disruption to the system.
Credits:
Thanks to Dilip M. Ranade (dmr's blog) for his suggestions for adding Thrashing and Deadlocks.
Thanks to Shivakalyani Ankam for her suggestion about Zombie Processes.