Thursday, August 18, 2011

Arm Twisted Logpgal Bill

Dear Indians

When the inspirational people of our country where busy shouting slogans,
I realized that despite my love for my country i never felt connected or
I was more of a deaf, but cleary some thing was a miss.
One of the common public perception in today's India is every thing which
we see stand on is common ground that is corruptionm we forget to understand
it starts from us, we need to educate our self to follow the right path. I
remeber the phrase written on first page of your books, if there is some
confusion do what is right for the most poor creature you have seen.

Anna goes for fast, media compares him with Mahatma, In his own words Mahatma
said Fast is a tool to self purification. It seems today is arm twisting
democratically elected representative of people of india. India's government
pillars legislative, administration, judiciary have been meek viewer to
the social drama. In Pre-independence era the laws of country where made
in some foreign land which where directly proportional with profit loss. I
am not sure if we can compare current situation with that. Even though
gandhi did fast for social causes like his fight against a ban on temple
entry for Dalits in Kerala or fighting untouchability in various corners
of India were more against local authorities. In current scenario our laws
are made for us in India out land. This situation is very critical leaders
do not know what to do with such situation.

How can some one outside from parliament choose themselves to lead some thing
called civil society, who is responsible the laws they are making becomes
a tool for some one destablize governments in comming years. People choose
elected members and hence share the responsibility for any wrong, there is
a great disconnect between government, people and administration. This
country is not just pockets of Delhi or Bombay, It is very big what happens
if accept the laws they say, those people who have elected the parliament
will we do justice. we need to think about this.

Yes we need a strong Bill which stops curroption but let the parliament
decide the right and if we think we need a stronger bill wait for election
do your duty to vote.

Thanks and regards
Vijayendra Suman

Monday, February 7, 2011

story of average engineer

Woman Age - 34
Man's Age - 45

A woman in a hot air balloon realized she was lost. She reduced altitude and spotted a man below. She descended a bit more and shouted, "Excuse me sir, can you help me? I promised a friend I would meet him an hour ago but I don't know where I am."

The man below replied, "You're in a hot air balloon hovering approximately 30 feet above the ground. You're between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude."

''You must be an engineer," said the lady balloonist. "I am", replied the man. 'How did you know?'

''Well", answered the lady in the balloon, "everything you told me is technically correct, but I've no idea what to make of your information, and the fact is I'm still lost. Frankly,you've not been much help to me at all. If anything, you've delayed my trip even more."

The engineer below responded, "You must be in Top Management." ''I am", replied the lady balloonist,"but, how did you know?''

"Well," said the Engineer, "You don't know where you are, or where you're going. You made a promise, which you've no idea how to keep, and you expect people beneath you, to solve your problems."

Saturday, December 4, 2010

Signals Not Working with threads

Here is small problem which i would like to share

1 #include
2 #include
3 #include
4 #include
5
6 //volatile int i = 0;
7 int i = 0;
8
9 //res = l;\
10 res = (l && l++); \
11
12 #define COND(l, x, res) \
13 pthread_mutex_lock(x);\
14 res = (l==0?l++:l && l++); \
15 pthread_mutex_unlock(x);
16
17 #define MSG_START "Message Start %s .. 0x%x\n", __func__
18 #define MSG_END "Message End %s .. 0x%x\n", __func__
19
20 void *thread(void *p1);
21 inline void CatchInterrupt (int signum)
22 {
23 /* there is no need to lock any variable in the signal handler
24 * the current context of the process is freezed and the execuation
25 * is set in the signal handler
26 */
27 i = 0;
28 }
29 void *thread(void *p1)
30 {
31 unsigned int res;
32 pthread_mutex_t *p = p1;
33 printf(MSG_START, pthread_self());
34 do{ /* Tight Loop */
35 COND(i, p, res);
36 }while(res);
37 printf(MSG_END, pthread_self());
38 return NULL;
39 }
40 int main()
41 {
42 const pthread_mutexattr_t *attr __attribute__((restrict));
43 attr = NULL;
44 pthread_t tid1 = 0;
45 pthread_t tid2 = 0;
46 pthread_t tid3 = 0;
47 pthread_t tid4 = 0;
48 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
49 i++;
50 signal(SIGINT, CatchInterrupt);
51 pthread_mutex_init(&mutex, attr);
52 pthread_create(&tid1, attr, thread, &mutex);
53 pthread_create(&tid2, attr, thread, &mutex);
54 pthread_create(&tid3, attr, thread, &mutex);
55 pthread_create(&tid4, attr, thread, &mutex);
56 pthread_join(tid1, NULL);
57 pthread_join(tid2, NULL);
58 pthread_join(tid3, NULL);
59 pthread_join(tid4, NULL);
60 pthread_mutex_destroy(&mutex);
61 return 0;
}

Compile this with gcc, mine version was
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33) Thread Model - posix

When run, I need to give 4 SIGINT to kill the process, But when we change the

line

res = (l && l++); \
with
res = (l==0?l++:l && l++); \

I need to give 1 SIGINT to this process ID, this should be correct behavior,

Can any one share what is reason.