Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help with Condition Variables
New Posts  All Forums:Forum Nav:

Help with Condition Variables

post #1 of 2
Thread Starter 
Condition variables confuse me and google isn't really helping. Is there anybody who could explain their use to me?
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
post #2 of 2
http://www.cs.mtu.edu/~shene/NSF-3/e...ONITOR/CV.html

You might have already seen this page or perhaps not. I haven't used it before but it seems pretty straight forward. Seems similar to the unix signal handler.

Some stuff from wiki: http://en.wikipedia.org/wiki/Monitor...tion_variables

Relevant section of code
Code:
conditionVariable {
  int queueSize = 0;
  semaphore lock;
  semaphore waiting;
  
  wait() {
     lock.acquire();
     queueSize++;
     lock.release();
     waiting.down();
  }
  
  signal() {
     lock.acquire();
     while (queueSize > 0){
        queueSize--;
        waiting.up();
     }
     lock.release();
  }
}

Edited by decompiled - 6/27/08 at 9:17pm
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  hide details  
Reply
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help with Condition Variables