The example: It works perfectly on Linux at the time – the timed_wait waits for 10 seconds and then returns false. However if I move the system date to 2116 year and re-run the app, the timed_wait call returns false immediately. There is the same problem with the boost’s condition vars. Could please anybody explain what’s wrong with it? Info:
Tag: c++
Is it safe to assume memory page size is a power of two?
I am currently working on a portable C program which makes use of the memory page size (as returned by sysconf(_SC_PAGESIZE)). I know most often page size is a power of two to allow efficient management using bitwise operations; I found no guarantee of this anywhere, though. So how safe is it to assume page size is a power of
client stops connecting to server after 2-3 successful connections. socket programming in c
I am trying out simple client-server program using socket programming in c. The program works fine when I execute server first and then client but after two to three successful executions, the client stops connecting to the server. This again starts working if I execute the programs after a certain amount of time. Client code: Server code: Executing client in
Netbeans Cpp compiles and runs project, but not test with cppunit
I have a C++ project using libraries such as wiringPi and MySQL Connector. My regular project compiles normally when I run it. When I try to Test one of my tests, it fails building the project. Here’s the output: The tests used to work before the implementation of the DatabaseAdapter & SerialDriver classes. I have added library options to the
dynamic_cast fails between “long distance” siblings on linux compilation
There is a class DerivedClass which inherits from both BaseClassA and BaseClassB publicly. All classes have virtual functions to make sure the virtual table is built properly. BaseClassA and BaseClassB are located in Library1 and DerivedClass is in Library2. One function in Library1 retrieves a DerivedClass in the form of a BaseClassA pointer and tries to dynamic_cast to BaseClassB but
qt run shell commands via qprocess
I am developing a small QT application to interact with the terminal, to send commands to the terminal and to read back information printed out. Example: get output of all processes using ps -aux PROBLEM I am able to write information out to the terminal but I dont think it is in the system scope, actual example: Command passed to
How to properly set up ALSA device
Edit: This question is different than the proposed duplicate because I’m asking How do you set the period/buffer size that will work with multiple targets each with different sound hardware?. I have created some code that attempts to set up ALSA before playback of an OGG file. The code below works on one embedded Linux platform, but on another it
uninterrupted execution of Cpp Linux code
Hi is there a method on which I can make my code safe from other OS interrupts etc in Linux GNU? For example if I have the code below and I need to find the exact execution time without other things interrupting my code. I have already looked into pthread_mutex_lock(&cs_mutex); but wasn’t able to stop other operations to run. Answer
compiling c++ projects with dlib library on linux
I want to use dlib library for my c++ projects in linux. I have installed it successfully and able to compile and run the .cpp samples files given under the dlib. I have compiled the sample files through the “g++ -std=c++11 -O3 -I.. ../dlib/all/source.cpp -lpthread -lX11 example_program_name.cpp” given in [http://dlib.net/compile.html][1] but I am unable to use the same command to
Does context switching works everytime, or does it result in unexpected behaviour?
In the below code my friend has stimulated a dead lock situation with context switching and mutex lock in linux. The problem is, after execution it printed Statement 1,3 and 4 But the correct output should have been statements 1,3 and 2 But when I change the value of sleep in func2 to sleep(4) It works fine. And if I