Skip to content

Commit

Permalink
Removes old semaphore methods from simulator.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Jan 5, 2016
1 parent 52bc6bc commit 46aac5c
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions HAL/SimulatorHAL/HALSemaphore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ internal static void Initialize(IntPtr library, ILibraryLoader loader)
Base.HALSemaphore.GiveMultiWait = giveMultiWait;
}


[CalledSimFunction]
public static IntPtr initializeMutexRecursive()
{
MUTEX_ID p = new MUTEX_ID { lockObject = new object() };
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(p));
Marshal.StructureToPtr(p, ptr, true);

return ptr;
}

[CalledSimFunction]
public static IntPtr initializeMutexNormal()
{
Expand Down Expand Up @@ -76,50 +65,6 @@ public static void giveMutex(IntPtr sem)
Monitor.Exit(temp.lockObject);
}

[CalledSimFunction]
public static IntPtr initializeSemaphore(uint initial_value)
{
var p = new MULTIWAIT_ID {lockObject = new object()};
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(p));
Marshal.StructureToPtr(p, ptr, true);

return ptr;
}


[CalledSimFunction]
public static void deleteSemaphore(IntPtr sem)
{
Marshal.FreeHGlobal(sem);
sem = IntPtr.Zero;
}

[CalledSimFunction]
public static sbyte takeSemaphore(IntPtr sem)
{
var temp = (MULTIWAIT_ID)Marshal.PtrToStructure(sem, typeof(MULTIWAIT_ID));
Monitor.Enter(temp.lockObject);//temp.semaphore.WaitOne();
return 0;
}

[CalledSimFunction]
public static sbyte tryTakeSemaphore(IntPtr sem)
{
var temp = (MULTIWAIT_ID)Marshal.PtrToStructure(sem, typeof(MULTIWAIT_ID));
bool retVal = Monitor.TryEnter(temp.lockObject);

return retVal ? (sbyte)0 : (sbyte)1;
}

[CalledSimFunction]
public static sbyte giveSemaphore(IntPtr sem)
{
var temp = (MULTIWAIT_ID)Marshal.PtrToStructure(sem, typeof(MULTIWAIT_ID));
if (Monitor.IsEntered(temp.lockObject))
Monitor.Exit(temp.lockObject);
return 0;
}

[CalledSimFunction]
public static IntPtr initializeMultiWait()
{
Expand Down

0 comments on commit 46aac5c

Please sign in to comment.