Thread: omp locking indices in array

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    110

    omp locking indices in array

    Whats the fastest lock to use when a few indices in an array is to be locked? I've only used pthread before, so be patient. :-)
    Example:
    Code:
    some global array = {0,1,2,3,4,5,6,7,8,9}
    ...
    //omp section
    one processor needs to lock indices 3,5,6
    
    for(i:loop through 3,5,6)
    which lock on : 
    array[i]
    I don't really know how to implement the idea above. I hope it is possible to understand what it is I want to do... Please enlighten me. :-)
    Last edited by überfuzz; 02-13-2014 at 07:58 AM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Why do you need to lock?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Code:
    for(i:loop through 1-5)
    which lock on :
    array[i]
    Code:
    for(i:loop through 2-6)
    which lock on :
    array[i]
    Code:
    for(i:loop through 1, 6)
    which lock on :
    array[i]
    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resize array values of "empty" indices
    By monkey_c_monkey in forum C++ Programming
    Replies: 2
    Last Post: 07-09-2012, 01:22 PM
  2. Replies: 6
    Last Post: 12-07-2011, 06:23 PM
  3. XNA 3d - 32 bit indices
    By musicman in forum Game Programming
    Replies: 1
    Last Post: 09-06-2011, 10:15 PM
  4. enum constants as array indices
    By hzmonte in forum C Programming
    Replies: 2
    Last Post: 01-23-2006, 08:23 PM
  5. Array of indices
    By ronenk in forum C Programming
    Replies: 4
    Last Post: 06-15-2004, 05:36 PM