If I do a pthread_join in fopen_t() it works perfectly fine. But if I do that in main() I get a segmentation fault error. I want to call it in main() because I want it to be non-blocking, is there any solution?
I'm quite new to openMP, mostly used pthreads and mpi before. Now I like to tinker a bit with openMP, but haven't found any good docs, reference list or similar.
What's the equivalent to pthread's mutex lock in openMP?
Code: #pragma omp parallel for for(i=0; i<n ; i++){ // Do something intelligent... // If needed handle a shared variable. }
I am working on the producer-consumer problem and am mostly happy with what I have except for one remaining issue. I am using pthreads for consumers and producers on a FIFO, and synchronizing using a combination of semaphores and mutexes. Things seem to work fine, except that my consumers seem unable to tell when there may be more data coming into the FIFO.
I need to be able to determine not just when the FIFO is empty (it gets emptied every time a consumer thread runs) but when ALL producers have detached from it - that's when my consumers should pthread_exit, and not before that. I have read conflicting information on how FIFOs work in terms of EOF and have been unable to get it working.
(NOTE: that's what I *think* the problem is... It's my first time working with pthreads, so there may be other issues I am not even aware of).
In any case, my code is below. I am running it on a Linux VM on top of Windows, if that makes any difference. It takes 3 command line parameters - FIFO name (will be created if doesn't exist), number of producers, and number of consumers.
I have looked on this website and stumbled across this link: [URL] .....
My question is can how do I use that code when im console programming?
When I try this code I get errors.
" line |14|error: initializer expression list treated as compound expression|" " line |17|error: a function-definition is not allowed here before '{' token|" "line |40|error: expected '}' at end of input|"
Code: #include <iostream> using namespace std; int main() { int MouseMove(100,100); void MouseMove (int x, int y ) {
How join two strings? basic reason is add given filename little text to end. I try do by hobby not school project program which converts files format x to format y.i dont say which formats becouse reading and writing is almost done. (only little amount code is needed).'
So, I'm making a program in C++ that emulates a full screen console... I used SetCurrentConsoleFontEx to set the font to 12x16 but it sucks...
Anyway, I read here: [URL] .... that also the console font can be changed, but I can't make it work! How can i set the font to Lucida Console? This is the function I use to change font size:
I am doing Histogram using pthreads and after long struggle on it.. finally it says 'Segmentation Fault (Core Dumped)'. I knew that error means something somewhere I am accessing to a wrong memory location.
I have to check whether or not a record exists in a join and if not ignore that user but still load all the other information for that user
var db = Simple.Data.Database.OpenNamedConnection("sqlConn"); var expr1 = db.PON_APP_USERS.STATUS == 1; var sUsers = db.PON_APP_USERS.FindAll(expr1) .Select( db.PON_APP_USERS.USERKEY, db.PON_APP_USERS.LAST_NAME, db.PON_APP_USERS.FIRST_NAME,
how to structure my classes so that they all "wire together" and inherit the proper functions and data that I want them to. I want to have a Car.c and car.h which are "wired" with body.c/body.h, which in turn is wired with a frame.c/frame.h, wheel.c/wheel.h, and driver.c/driver.h.
Each part of the car holds some type of data, mostly ints: The car has a (total) mass and car_name. The body has a mass and color. The frame has a mass. The wheel(s) have a mass and force. [There will be 4 instances of wheel] The driver has a mass and driver_name. Each of these functionalities must come from their respective .c and .h files, and be amalgamated in the car.c and car.h (which should contain all the functionality of its parts). Then, in my main test program, I am to make an instance of car and hardcode in its values of: mass (which comes from the total mass of all of its parts, this is where i start to lose it.
How will I access its parts' masses in the test program?), color (a character array), current position (an integer), current velocity (an integer), and current acceleration (which comes from the total newton force of the 4 wheels, again this is where I start to get very confused). (Then in the test program I am to print out a simulation of this car over a period of 100 seconds, and show its position, velocity, and acceleration at each point (based on the mass, total newton force, and starting position). This part is of course a simple while loop, and is somewhat trivial.)
From what I understand, I will need to allocate memory for all of the data each class holds. Then, using function pointers, as well as #include "X.h" , I will need to somehow link up all of the classes together so that car has access to all of the parts' functions which set, for example, the newton force of each wheel.
We have learned a slight bit about structs, malloc, sizeof, and pointers, but I have not used them to link functionality or data from separate classes together.
I have written an program to emulate a shopping list. Everything works fine, until I try to read in from a file. Here is my read and write code (the write code looks like it is working ok, but I figured I would include it just in case), and an example of what happens to a list that has been written, then read back in.
I took this list, and wrote it to a file, then read that file back in. The .txt file looks like everything was written out properly, but when I try to read that exact same list back in, this is what I get:
I am puzzled with the strange behavior of my code below. The code has an apparent error but the results are correct. I am trying to put two arrays (chara and shuffled) into a third array join. The first 10 elements of 'join' should have the elements of 'chara' and the second half should have the elements of 'shuffled'.
You will note that in the second For loop, I am using 'chara' instead of 'shuffled' but when I print the contents of 'join' I am getting the correct numbers.
On the other hand if I replace 'chara' with 'shuffled' in the second For loop, I am getting incorrect results.
1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,
Why is this happening? (I am using Codeblocks.)
#include <iostream> #include <stdio.h> using namespace std; int main() { int chara[]={1,2,3,4,5,6,7,8,9,10}; int shuffled[]={11,12,13,14,15,16,17,18,19,20};
I have a problem: solve the system of equations by the Gauss-Jordan methods with pthreads. I have a big matrix A (for example 2000x2000), so i must solve Ax = b. Before I devide matrix to number of threads and each thread must work only with his peace of matrix.
Code: #include <iostream> #include "synchronize.h" #include <pthread.h> using namespace std; typedef struct _ARGS { int thread_count; int thread_number;
[Code] .....
I write it on Ubuntu, and when I compile [g++ main.cpp -o main -lpthread -lm] the it works good(for example, if in 1 thread I get time_of_working = 10 sec, on 2 threads time_of_working = 5.4, i.e. about 2 times faster ), if I compile like this [g++ main.cpp -o main -lpthread -lm -O3] it is only 1.2-1.3 times faster.
i have to create a console based application in c language that can join and split bitmap images. the requirements of the application are as follows :
1. Split Image Enter number of parts: Enter source image path: Enter destination folder: 2. Join Images (all images should be of same width and height) Enter image path: Join more Image (y/n): 3. Exit
Take care of following things:
- Application should show number of images processed while running. - Acceptable Image format is BMP only. - Application should give all the validations for correct image name, type, size, path, etc.
I have made a calendar that looks similar to Outlook, and I have the next/previous buttons, but they don't do anything when you click them. how to create the callback so that when I click next it goes to the next month?
I want to do a basic thing but for some strange reason there is something not working.
I need to write to a file but I'm handling all the code in a callback function, which in turn is declared in a class. Here is the architecture of my code:
Code: int main (int argc, char **argv) { ImageConverter Aclass; while(1); //infinite loop return 0;
[Code] ....
But this doesn't work, the file gets created but it allways overwrites itself which is not what I need to do.
What I am doing wrong? Is it because i am constantly declaring outfile?
There is already a thread with exactly the same problem I have, but the answer to solve the problem isn't stated at the end. Problem with callback as classmember.
I have a function (name Callback), with take some parameter( name Arg). I want to create it before, pass it to other class ( class B). And in class B, call the Callback function with Arg paramater. It's something like this:
class A { void A::doSomething(int a, bool b){//dosomething}; void A::setCallback(B b) {//I don't know how to do this};
[Code].....
How can i do this? And what happen with I want B can get more type of callback function, which mean I don't know the type of Callback's paramater?
I have an application based around a WCF Duplex service. I have problems when the user "Restarts" the work the application does... under the hood, the client side closes the connection to the WCF service and creates another. The Service contract is defined like so...
[ServiceContract(Namespace="net.tcp://namespace.MyService", SessionMode=SessionMode.Required, CallbackContract=typeof(IServiceCallback))] public interface IMyService { [OperationContract(IsOneWay=true)]
[Code] ....
The issue I see is that the _context.Close() call always times out and throws an exception. Although I'm then aborting the channel, this feels wrong to me, and I believe it's the cause of freezing in my application. Why the Close() call fails?
I missed something earlier regarding my callback implementation that might be relevant. It looks something like this:
[Callbackbehavior(ConcurrencyMode = ConcurrencyMode.Single, UseSynchronizationContext = false, IncludeExceptionDetailInFaults = true)] public class CallbackImplementation : IServiceCallback { public void SendMessage(string message){ // Do something with the message } }
The exception message is "The ServiceHost close operation timed out after 00:00:30. This could be because a client failed to close a sessionful channel within the required time. The time allotted to this operation may have been a portion of a longer timeout.". There's no inner exception.
The big problem is that the client application freezes when the main application process is started after one client has been disposed and a new one created. I've also noticed that when you close the WPF application, it doesn't close properly and keeps running in the background, preveting you from starting a new instance.
Is it possible to read NFC card reader in VC++/MFC. Is it possible to develop a callback function that will read the NFC device, and see once the card is inserted, it takes that value from the card and store it in a DB?
I have a problem with an extension DLL that has an exported function. The function is being exported ok, it is called by a Windows service. The Windows service is using the exported function, and everything works. I am trying to create a file with:
But nothing happnes however. There are no errors, the file is just not created. Also, if i try to call MessageBox() in the exported function, nothing happens as well . I have a .h file which exports the function with __declspec(dllexport) DWORD WINAPI functionName(), and also a .cpp file with the function definition. There is no main().