Wednesday, May 5, 2010

How to write a Hello World program for multi-billion users

1 - Some current news, some inspirations

2 - Some technical viewpoints

" Functional programming - treats computation as the evaluation of mathematical functions and avoids state and mutable data. "

So what am I thinking? The mutable data means, you have to or "must" control which function takes this data first if there are some functions concurrently refer to it.
Normal case:
Integer n = 1;
n = n + 1;
You get 2
Concurrent case:
Integer n = 1;
A thread do n = n + 1;
A another thread do n = n - 1;
2 threads use the shared object "Integer n".

2.1 - The waiting for your dinner

  • What happens when you share a fork with your friend. You have to wait him.
  • Yes, you must use a lot techniques to solve some classic multi-process synchronization problems.
  • One of them is the dining philosophers problem(
  • I notice the deadlock happens as it describes "The philosophers never speak to each other, which creates a dangerous possibility of deadlock when every philosopher holds a left fork and waits perpetually for a right fork (or vice versa).
  • The cause of this problem is "the shared resources" , here is the fork. We have 5 philosophers , and just 5 forks for them.
  • If each philosopher has 2 forks, so nothing to share, and everyone can take his dinner independently.

2.2 - How to write a Hello World program for multi-billion users

In practice, what happens when you develop a system for multi-billion users. If you use the Google, you will understand what I mean.

View more presentations from xlight