Hi;
I have a c program that uses mpi library to run on parallel arhitecture. First i coded serial program and it worked perfectly. But the parallel one did not run. I found the error but could not solve it.
The error is: the "fseek" and "fread" functions does not return the correct values. - fseek(wav_fp,40L,SEEK_SET);fread(&str,4,1,wav_fp);
this code must return "str" = "81913" but i get "-442495"
Thanks.
7 5871
Are you reading as text or as binary??
Are you reading as text or as binary??
As binary..
In serial version of this code runs true as parallel program with mpi library can not get the right result.
Then you have a multithreading race operating.
If this file is a shared resource, you may have to access it within a critical section.
no, it is not multithreading program, it is a parallel program, the fseek's offset value is long type and this is causing segmentation fault problem.
I'm sorry but what is the difference between a parallel program and a multi-threaded one??
in parallel programing a processor executes a part of the job, but in multi-thread programming whole job is done by one processor.
in parallel programing a processor executes a part of the job, but in multi-thread programming whole job is done by one processor.
This statement is absolutely false.
A parallel program is a program where sections are run in parallel in real time. This requires multiple processors. Each processor runs a section. Each section is called a thread.
A multi-threaded program is a program that can be run as a parallel program. It can also be run using one processsor but only one thread executes at a time. The operating system will multi-task to make it appear that there is more than one processor giving the illusion that the threads are running in parallel.
You have to be certain that any data shared between threads is protected by a critical section, mutex, sempaphore, spin-lock or something that prevents two threads from writing simultaneously to the same resource.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Leslaw Bieniasz |
last post by:
Hello,
I am trying to fastly read large binary files (order of 100-200 MB)
using ftell() and fseek(). My class gets a pointer to the
data stored in the file, and then uses fseek() to access
and...
|
by: Christopher Benson-Manica |
last post by:
On thinking about the "replace a word in a file" thread, I wondered how easy
it would be to accomplish the same thing with only one file pointer. This led
me to some questions...
"For a text...
|
by: TJ Walls |
last post by:
Hello All,
I am baffled ... I am trying to improve the speed of a program
that I have written that performs random access within a file. It
relies heavily on fseek and is very slow. To test, I...
|
by: Xenos |
last post by:
Can anyone tell me what the standard says about using fseek (on a binary
file) to seek past the end-of-file? I can't find anything in my (draft)
copy of the standard, nor in the FAQ.
Thanks
|
by: cedarson |
last post by:
I am writing a program and have been instructeed to use the 'fseek',
'ftell', and 'stat' functions, however, after looking in the online
manual for each of these, I am still unsure on how to use...
|
by: Kenneth Brody |
last post by:
I recently ran into an "issue" related to text files and ftell/fseek,
and I'd like to know if it's a bug, or simply an annoying, but still
conforming, implementation.
The platform is Windows,...
|
by: Chen ShuSheng |
last post by:
HI,
I am now study a segment of codes:
------------------------
printf("%p\t",fp); /*add by me*/
fseek(fp, 0L, SEEK_END); /* go to end of file */
printf("%p\t",fp); ...
|
by: Dmitry Belous |
last post by:
Why when I uncomment fseek line buf become empty?
#define _GNU_SOURCE
#include <stdio.h>
int main() {
char *buf = 0;
int size = 0;
FILE* f = open_memstream(&buf, &size);
fwrite("test", 1, 4,...
|
by: ericunfuk |
last post by:
A basic question:
When the documentation says "fseek() clears EOF indecator, does it
mean when you seek over EOF, EOF is no longer at the original position
and hence removed?Say, after I seek...
|
by: thomas.mertes |
last post by:
Hello
Recently I discovered some problem. I have some C code
which determines how many bytes are available in a
file. Later I use this information to malloc a buffer of
the correct size before...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
| |