Hi nkhambal ,
actually i have tried to run the 1st code u posted, it works fine.
but i get these warnings:

s1.c: In function ‘alarm_wakeup’:
s1.c:35: warning: incompatible implicit declaration...