In C, when i have a shared object between many threads, but i can guarantee that it will not be modified, can i restrict-qualify a pointer to it? Of course, in each individual thread the usual requirement, that the pointer provides exclusive access to the object, holds. But considering all threads, the access isn't really exclusive anymore, since every thread has a pointer. Is it still valid to use restrict on this pointer?
Is it valid to use restrict on read-only objects shared between threads in C?
39 Views Asked by Finn At
1
There are 1 best solutions below
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in PARALLEL-PROCESSING
- How to calculate Matrix exponential with Tailor series PARALLEL using MPI c++
- Efficiently processing many small elements of a collection concurrently in Java
- Parallelize filling of Eigen Matrix in C++
- Memory efficient parallel repeated rarefaction with subsequent matrix addition of large data set
- How to publish messages to RabbitMQ by using Multi threading?
- Running a C++ Program with CMake, MPI and OpenCV
- Alternative approach to io.ReadAll to store memory consumption and send a PUT Request with valid data
- Parallelize nested loop with running sum in Fortran
- Can I use parfor within a parfeval in Matlab R2019b and if yes how?
- Parallel testing with cucumber, selenium and junit 5
- Parallel.ForEach vs ActionBlock
- Passing variable to foreach-object -parallel which is with in start-job
- dbatools SQL Functions Not Running In Parallel While SQL Server queries do in Powershell
- How do I run multiple instances of my Powershell function in parallel?
- Joblib.parallel vs concurrent.futures
Related Questions in RESTRICT-QUALIFIER
- Why can a fpos_t * alias a FILE *?
- Do C compilers follow the "formal definition of `restrict`"?
- When is `T *restrict`'s no-aliasing guarantee enforced?
- restrict qualifier for different types
- Can restrict qualifier be used to hint to the compiler that external functions won't modify your memory?
- Does a restrict-qualified pointer parameter of a function allow optimization of the caller functions?
- Formal definition of restrict fails to account for valid cases
- restrict keyword ignored by the compiler when not passed as function parameters
- Inferring non-aliasing solely from restrict pointer parameter declarations
- What does the usage of restrict mean in the man page for 'fwrite'?
- What happens if memory for a format string is shared with one of the arguments of printf?
- Should GCC/Clang optimize this redundant load via an array of restrict-qualified pointers?
- Using restrict pointers within structure in C
- Linux memcpy restrict keyword syntax
- Can 2 `restrict`-ed pointers compare equal?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If an object is not modified, then it is always fine to access it via a
restrict-qualified pointer, no matter how many times or where it is done.The semantics of
restrictare defined in 6.7.3.1 p4 (C17 N2176):If your object X is not modified by any means during the execution of any block B where you would use the
restrictpointer, neither by this thread nor any other, the requirements that follow do not apply, and there are no other requirements related torestrictthat would apply.(In a multi-threaded program, I presume the intended interpretation of "not modified during the execution of B" would be that any modifications of X must either happen before the evaluations in the block B, or vice versa.)