I have written a kernel module, It I am using a semaphore
.
In init_module
, semaphore
is initialized and calling semaphore down() call
once.
In device
file read()
function I am having semaphore down()
call followed by memcpy()
.
In interrupt handler only semaphore up()
call;
There is a user application which only reads from devfile
and displays;
The hardware will give interrupt after every frame data transferring completed.
The problem is in executing the functions respectively.
After inserting the module, semaphore
value is -1
.
According to my understanding when i execute the user application it is waiting at read()
function (trying to down the semaphore again).
When interrupt handler is executed semaphore is up once (now semaphore value 0).
Then read function also success.
Here the problem is the first read function is displaying garbage values and next onwards correct.
So please any one can say why this garbage values in first read..? Expected value is first frame data.....