OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [aeMB/] [sw/] [aemb/] [semaphore.hh] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 alirezamon
/* $Id: semaphore.hh,v 1.1 2008-04-28 20:29:15 sybreon Exp $
2
**
3
** AEMB2 HI-PERFORMANCE CPU
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU General Public License as published by
10
** the Free Software Foundation, either version 3 of the License, or
11
** (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
** License for more details.
17
**
18
** You should have received a copy of the GNU General Public License
19
** along with AEMB.  If not, see .
20
*/
21
 
22
/**
23
   General semaphore library
24
   @file semaphore.hh
25
 */
26
 
27
#include "thread.hh"
28
 
29
#ifndef _AEMB_SEMAPHORE_HH
30
#define _AEMB_SEMAPHORE_HH
31
 
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
 
36
  // TODO: Extend this library to include threading mechanisms such as
37
  // semaphores, mutexes and such.
38
 
39
  /**
40
     Semaphore struct.
41
     Presently implemented as software solution but a hardware one may be
42
     required as the threads are hardware.
43
  */
44
 
45
  typedef int semaphore;
46
 
47
  /**
48
     Software Semaphore Signal.
49
 
50
     Increment the semaphore and run. This is a software mechanism.
51
  */
52 48 alirezamon
  static inline void aembSignal(volatile semaphore _sem)
53 17 alirezamon
  {
54
    _aembLockMTX();
55
    _sem++;
56
    _aembFreeMTX();
57
  }
58
 
59
  /**
60
     Software Semaphore Wait.
61
 
62
     Decrement the semaphore and block if < 0. This is a software
63
     mechanism.
64
  */
65 48 alirezamon
  static inline void aembWait(volatile semaphore _sem)
66 17 alirezamon
  {
67
    _aembLockMTX();
68
    _sem--;
69
    _aembFreeMTX();
70
    while (_sem < 0);
71
  }
72
 
73 48 alirezamon
 
74 17 alirezamon
 
75
  /**
76
     Implements a simple rendezvous mechanism
77
   */
78
  /*
79 48 alirezamon
  static inline void aembRendezvous()
80 17 alirezamon
  {
81
    if (isThread1())
82
      {
83
        wait(__mutex_rendezvous0);
84
        signal(__mutex_rendezvous1);
85
      }
86
    else
87
      {
88
        signal(__mutex_rendezvous0);
89
        wait(__mutex_rendezvous1);
90
      }
91
  }
92
  */
93
 
94
#ifdef __cplusplus
95
}
96
#endif
97
 
98
#endif
99
 
100
/*
101
$log$
102
*/

powered by: WebSVN 2.1.0

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