Thursday, April 15, 2010

The Naughty Cooker

A knock on the door----
my sweet, vivid dream it tore.
Half-asleep I opened it,
to my surprise there was kept a kit.

The kit was like a big basket--
contained in it was a cooker and gasket.
I kept it aside and tried to sleep,
Noise again woke me, just at the dream leap!

Oh God! whats that?
Terrified I went to the kitchen
The cooker was sneezing like a chicken

After putting all things in order
When I was to sleep and was on border,
There was a sound similar to that of an explosion,
At a time, when I was swimming in the dream ocean.

Peeping out of my room, What I found
was everywhere 'khichdi' scattered a pound
God forbid, this naughty cooker
Had at last burst like a boomer!

Annoyed, at the cooker, I lost my temper
called the number and started to hammer,
The head of the cooker repairer;
Before I found it was a wrong number!

Sunday, April 11, 2010

Structure of Implementation (original One)

I drew it as an ASCII figure in the proposal and something unusual happened with the whitespaces, thus the figure became a mess. Please use this one for further reference.

Tuesday, April 6, 2010

Implementation of lamport's clock in Python

Here goes the

p = dict()
event = dict()
def clock():
    """local clock update"""
    procsno = int(raw_input("enter the no. of processes.\n"))
    for i in range(procsno):
        print "enter the events in process",
        eventno = int(raw_input(i))
        event[i] = eventno
        for j in range(event[i]):
            p[i,j] = j+1
            print i,j,p[i,j]
    mes = int(raw_input("please enter the no. of messages sent"))
    for i in range(mes):
        psen = int(raw_input("sender process"))
        esen = int(raw_input("sender event"))
        prec = int(raw_input("receiver process"))
        erec = int(raw_input("receiver event"))
        p[prec,erec] = lamportclock(psen,esen,prec,erec)
    for i in range(procsno):
        for j in range(event[i]):
            print i,j,p[i,j]

def lamportclock(si,sj,ri,rj):
    """global clock update by message passing"""
    q = p[si,sj]+1
    if q>p[ri,rj]:
        return q
        return p[ri,rj]

All reviews and errors and bugs report are solicited. I would be very happy to know if it helps you in your struggle with C implementation!
This one is really bad in the output view, though the internals is OK.
A better will be posted if I did work on it :P