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 7919927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:01:52+00:00 2026-06-03T16:01:52+00:00

I am using openmp and my program looks like as follows: \#pragma omp parallel

  • 0

I am using openmp and my program looks like as follows:

\#pragma omp parallel for

for(x = 0, y = 0, x < 5, x++, y++)

     function(x, y, fp);

void function(int x , int y, FILE* fp);
{
   fprintf(fp, "(%d, %d)\n", x y);
}

I want that the content of file as

(0, 0)
(2, 2)
(1, 1)
(3, 3)
(4, 4)

The ordering doesn’t matter but the coordinates x, y should be in order, ie the program should not generate something like (2, 3). Is this behavior always guaranteed? I am using gcc compiler on linux.

  • 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-06-03T16:01:54+00:00Added an answer on June 3, 2026 at 4:01 pm

    You have incompatible assumptions in your question. OpenMp is not part of the C standard, so the C specification can’t say anything about the thread model of OpenMp and ensure anything about safety of its proper functions. Until recently C didn’t even have a thread model.

    C11 now has its own thread model, and in that thread model the functions that operate on IO streams are thread safe:

    Each stream has an associated lock that is used to prevent data races
    when multiple threads of execution access a stream, and to restrict
    the interleaving of stream operations performed by multiple threads.
    Only one thread may hold this lock at a time. The lock is reentrant: a
    single thread may hold the lock multiple times at a given time.

    I don’t think that there is yet a compiler out there that implements C11 fully, but typically the C library on POSIX systems would fulfill this particular requirement. When there will be such a complying implementation, it would be up to the OpenMp implementation that would sit on top of it to document if its thread model would be consistent with the one of C11.

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

Sidebar

Related Questions

I am working with cuda and using openMP for parallel threading: #pragma omp parallel
My parallel program is implemented by using c++ and OpenMPI. When I test it,
I am writing a multi-threaded program using OpenMP in C++. At one point my
I'm a newbie using OpenMP with C++. I was doing a simple function, loading
I am using OpenMP to parallelize loops. In normal case, one would use: #pragma
I have a very weird problem using OpenMP in my C++ code: void update(double
please help me to make this code parallel using openmp this code is run
I have a C++ program which is working quite well using OpenMP to parallelize
I have a C++ program using OpenMP, which will run on several machines that
i am trying to use OpenMP in my program (i am newbie using OpenMP)

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.