[Prev][Next][Index][Thread]

a possible bug in osenv_timer_init ?



a classical one, I guess:
(excerpt from "oskit/dev/x86/timer.c")
 
 static int initialized = 0;  /* guard against multiple invocations */
...
A:
 if (initialized)
  return;
B:
 initialized = 1;
...
 
suppose two invocations occur (I guess this can occur, if drivers are implemented as separate processes and two request independantly of each other a timer initialization, however this can easily be removed, if the OS calls it when initializing itself, before loading any other drivers...). one gets to label B before switched, other one gets execution control and again executes up to B, since the variable will be still 0... Solution: a lock? I know there is no lock in the osenv_ API... but I will try to implement it, once I get to know the code better :).
FtpDaemon