llnl / llnl/HPC-Tutorials

Suggestion on PThreads (passing argument, example3)

Open
#13 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
257
Forks
129
PR merge metrics
No merged PRs in 30d

Description

As from the title, in PThreads tutorial, Passing Arguments to Threads, Example 3
```
Example 3 - Thread Argument Passing (Incorrect)
This example performs argument passing incorrectly. It passes the address of variable t, which is shared memory space and visible to all threads. As the loop iterates, the value of this memory location changes, possibly before the created threads can access it.
```

```c
int rc;
long t;

for(t=0; t

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the PThreads tutorial's “Passing Arguments to Threads” section and its “Example 3 - Thread Argument Passing (Incorrect)” code and output. Compare the displayed output with the stated lesson about shared variable t changing before a thread reads it; done means the example and explanation consistently illustrate that point.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.