OpenCores
URL https://opencores.org/ocsvn/aemb/aemb/trunk

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [aemb/] [thread.hh] - Diff between revs 114 and 117

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 114 Rev 117
Line 1... Line 1...
/* $Id: thread.hh,v 1.3 2008-04-11 15:53:24 sybreon Exp $
/* $Id: thread.hh,v 1.4 2008-04-12 14:07:26 sybreon Exp $
**
**
** AEMB2 HI-PERFORMANCE CPU
** AEMB2 HI-PERFORMANCE CPU
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
**
**
** This file is part of AEMB.
** This file is part of AEMB.
Line 79... Line 79...
  required as the threads are hardware. This can be implemented using
  required as the threads are hardware. This can be implemented using
  a specialised add/sub/load register.
  a specialised add/sub/load register.
  */
  */
 
 
  class semaphore {
  class semaphore {
 
  private:
    volatile int _sem; ///< Semaphore in Memory
    volatile int _sem; ///< Semaphore in Memory
  public:
  public:
    /**
    /**
    Preload the semaphore
    Preload the semaphore
    @param pval preload value
    @param pval preload value
Line 100... Line 101...
    inline void wait() { _sem--; while (_sem < 0); } // block while
    inline void wait() { _sem--; while (_sem < 0); } // block while
                                                     // semaphore is
                                                     // semaphore is
                                                     // negative
                                                     // negative
  };
  };
 
 
 
  semaphore __mutex_rendezvous0(0); ///< internal rendezvous mutex
 
  semaphore __mutex_rendezvous1(1); ///< internal rendezvous mutex
 
 
 
  /**
 
     Implements a simple rendezvous mechanism
 
   */
 
 
 
  void rendezvous()
 
  {
 
    if (isThread1())
 
      {
 
        __mutex_rendezvous0.wait();
 
        __mutex_rendezvous1.signal();
 
      }
 
    else
 
      {
 
        __mutex_rendezvous0.signal();
 
        __mutex_rendezvous1.wait();
 
      }
 
  }
 
 
}
}
 
 
#endif
#endif
 
 
/*
/*
  $Log: not supported by cvs2svn $
  $Log: not supported by cvs2svn $
 
  Revision 1.3  2008/04/11 15:53:24  sybreon
 
  changed MSR bits
 
 
  Revision 1.2  2008/04/11 11:34:30  sybreon
  Revision 1.2  2008/04/11 11:34:30  sybreon
  changed semaphore case
  changed semaphore case
 
 
  Revision 1.1  2008/04/09 19:48:37  sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
  Added new C++ files
  Added new C++ files

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.