Faculty of Information Technology
Software Engineering Group

Opened 6 years ago

#167 new todo

Lock symbol database file only when its being updated

Reported by: Jan Vrany Owned by:
Priority: major Milestone:
Component: stc Keywords:
Cc: Also affects CVS HEAD (eXept version): no

Description

As of now, stc locks symbol database file while it's running. This prevents parallel builds as more than one stc may be accessing the symbol database file.

In most case the symbol is found in the database so no update is needed. stc should use shared read lock while reading it and exclusive write lock when updating it to allow parallel builds.

---
The functions that have to be fixed are:

  • lockSymFile(), unlockSymFile() (use OS-provided file locks)
  • call lockSymFile() and unlockSymfile() with read lock when reading it in readSymFile() and use write lock when updating it in findSymAddr().

As for the locking, on POSIX systems use POSIX file locks, on Windows, check following example:

// crt_fsopen.c      
#include <stdio.h>   
#include <stdlib.h>   
#include <share.h>      

int main( void )   {
      FILE *stream;
      // Open output file for writing. Using _fsopen allows us to
      // ensure that no one else writes to the file while we are
      // writing to it.
      //
      if( (stream = _fsopen( "outfile", "wt", _SH_DENYWR )) != NULL )
      {
         fprintf( stream, "No one else in the network can write "                          "to this file until we are done.\n" );
         fclose( stream );
      }
      // Now others can write to the file while we read it.
      system( "type outfile" );
}   

Change History (0)

Note: See TracTickets for help on using tickets.