dhylands at gmail.com
Fri Dec 24 04:00:53 EST 2010
On Thu, Dec 23, 2010 at 11:59 PM, Nilesh Tayade
<nilesh.tayade at netscout.com> wrote:
> I tried it, and it seems adding mutex_init() works as Mukti mentioned. I
> did get a kernel oops before (but no segfault). After adding
> mutex_init() there is no oops/segfault. The code, however, is reading
> the garbage, that needs to be fixed.
short a = *((short *)&n);
short b = *((short *)&n);
short c = *((short *)&n);
This sets a b and c to have essentially random values.
nbytes = read( fd, n, 40);
This causes the value of n to change. However, the values of a, b, and
c retain the same random values you assigned them above.
printf( "\r a = %d \n ", a);
printf("\r b = %d \n",b);
printf("\r c = %d \n",c);
This prints the random values of a, b, and c rather than printing thee
values of n that you read in.
More information about the Kernelnewbies