Week 2 - Pantheon

Gap-fill exercise

Fill in all the gaps, then press "Check" to check your answers. Use the "Hint" button to get a free letter if an answer is giving you trouble. You can also click on the "[?]" button to get a clue. Note that you will lose points if you ask for hints or clues!
Hey, Dad.

Cary: Hi.

Stir-fry.

With tofu and bok choy.

With tofu and bok choy.

Is that alright?

I thought you said something
about a home-cooked meal.

This is home-cooked.

Monday through Thursday,

all I eat is
take-out or room service.

- I don't understand.
- I see that.

This is home-cooked.
I... cooked it.

You've stated that twice now.
I haven't disputed it once.

- How's San Jose?
- How's school?

I got a call from Caspian's
calculus today.

She said he's ready
to take the AP exam now

and start a college course
next semester.

Well, it's good he's past that.
Differential calc's worthless.

[Scoffs] Worthless?

It's not practical
in the world.

'Less you wanna be a teacher.

You want to be a programmer?
Lambda.

Renee: Well, I thought
it was impressive.

And if you were hiring
for Centillion or Logorhythms,

your opinion -might have value.
- Caspian: I know Lambda.

Really?

So, if I were
to give you a ,

like the kind they throw
for an entry-level coder job,

- you could solve it?
- Renee: Cary.

You brought up math, Rene.
I'm just talking to my son.

I'm pretty tired.

Alright. I'll give you
an easy one, then.

Five geniuses sit around
a table, each with a bowl

of tofu stir fry
with bok choy in front of them.

There's one
between each guy,

therefore one
to the right and left.

In order to eat,
any given genius

needs to use both chopsticks.

They have to alternate eating
and thinking

because they can't do both
at the same time.

How do you make sure
all the geniuses

get their thinking done
without starving to ?

Renee: Well, I think
I know this one.

Each man takes a chopstick
to feed the man next to him.

That's a religious allegory
between heaven and hell.

This is a... A concurrent
algorithm problem.

So he knows what the problem is.
That is a start.

Assume infinite amount
of stir fry?

And infinite amount
of stomach space.

Maybe it is hell.

It's hard to avoid deadlock,
isn't it?

This is a shared
resource problem

that appears in programming
all the time.

Unh-unh. The guy on your right's
using that one.

He just wants to eat his dinner.

Quiet.

I give up.
I don't get it.

It's a hierarchy .

You assign a partial order
to the resources.

- Okay.
- You number the chopsticks one through five.

Each man picks up
the lowest number first

from the two in front of them,
and the order...

And the order they put them
down in doesn't matter.

If four of the five geniuses

pick up
the lowest numbered stick,

only the highest numbered
remains on the table,

leaving an odd man out
until the next round.

I thought you said
you didn't get it.

It's not practical
in the real world.

Unless your program only
has access to one .

Across multiple,
you'd have to release

higher numbered records
before accessing new ones

and your program would stall,
then crash, then you'd be fired.

Oh, but you do avoid deadlocks.

It's easy to poke holes
when you don't have a...

Introduce a third party. Someone
from the outside. A waiter.

An arbitrator that each genius
has to ask permission for

to lift their stick.

They can always put down,

but they must have
permission to lift.

Third party works as a mutex.
Reduces parallelism.

Wow, honey.

"Wow, honey." Do you n
understand one word he said?

I a lot of things.
I know he wasn't wrong.

- I know that.
- Here. Take mine, too.

Just like I know
what "home-cooked" means,

even if you don't.

It's "meal."
"Home-cooked meal."

It's not tofu, not kale.

Meat loaf!
Mashed potatoes!

You know? Food!