Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621674
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:44:07+00:00 2026-05-22T02:44:07+00:00

I am working on a lock free data structure, and am trying to CAS

  • 0

I am working on a lock free data structure, and am trying to CAS pointers.

When using compare and swap, what flags should I pass into the compiler?
I have gotten a license for http://locklessinc.com/ memory allocator.
I am also using netbeans 7.

Currently The only flags I have are under the linker, -march=native -lllalloc.

However when I run the program I get weird memory issues.
I think I may be missing a flag or two…
Also netbeans says “unable to resolve identifier __sync_bool_compare_and_swap” but it still compiles it.

Anyone have any ideas?

Data Structure:

struct Ambigous
{
    short type;
    union{
        struct{
            bool inCleanup;
            KEY key;
            VALUE value;
        };
        Ambigous* volatile list[MAIN_SIZE];//CHANGED ordering, still have netbeans error
    };

};

My Compare and swap code

bool res= __sync_bool_compare_and_swap(&(local->list[pos]), current_node, new_node);

How I allocate memory:

Ambigous *temp_spine = (Ambigous *) calloc(1,sizeof (Ambigous));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:44:08+00:00Added an answer on May 22, 2026 at 2:44 am

    __sync_bool_compare_and_swap is a GCC intrinsic. You don’t need any particular compiler flags for it; however, your IDE won’t be able to find its definition, because it doesn’t have one. And it may not work on other compilers; eg, the Visual Studio compilers call it InterlockedCompareExchange

    As for where your problem is, it’s hard to say without seeing the rest of your code. Lockless algorithms are very tricky to get right; it’s all too easy to miss some small race condition. Stick to locks unless you have a very good reason to do otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a lock free stack and queue data stracture where I can
I'm trying to note down workstation/System screen lock of each employee working in ubuntu
I am Working around MySQL error Deadlock found when trying to get lock; try
Error: 155004 (Attempted to lock an already-locked dir) Description: Working copy '/Users/Carrie/MyProjects/Sandbox/Flip/Classes' locked
On the project I'm working on, we have a file with svn:needs-lock that's frequently
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
I'm working on an iPad browser games and can't seem to lock the window.
I have created a folder lock in C#.NET which is working good on NTFS
I'm working a program that will have a bunch of threads processing data. Each
I am working on a program, which allows the user to lock the computer,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.