Let’s say I have a process A and a process B, and process A would like to pass a C string to process B through a shm_open() + mmap() shared memory. What’s the most latency efficient way? The answer of this post suggested that after C++11, std::atomic is the right way to share data over shared memory. However, I fail
Tag: c++
Draw table in C — like table on manual page of Linux
I want to make nice tables like you see on some manual page of Linux documentation in C programming language. Is there any library or functions to create a table like them. For example a table that you can find on man syslog like the following, produced by running man syslog: Answer You can take a look at the ncurses
Serial port hangs on close()
I developed this simple kernel module, which emulates a serial port by using a FIFO queue and a timer (read from hardware : out from the queue, write to hardware : insert in the queue). Source code is shown next. Then, I wrote a simple test-application which configures the port settings (baud rate, parity, stop bits, etc) and starts a
How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 4 years ago. Improve this question I am looking to write a program that will need to
Weird behavior in GDB when defaulting copy/move constructors
I have the following code which seems to behave weirdly in GDB depending if the copy/move constructors are defaulted or not. I fire up GDB, add a breakpoint on the last cout in main and run “p t.get()” and I expect it to be 42 but depending on the value of the macro CUSTOM I get either 42 (when CUSTOM
Control loop time with usleep
I try to make sure the execution time of each loop to 10ms with usleep , but sometimes it exceeds 10ms. I have no idea how to solve this problem, is it proper to use usleep and gettimeofday in this case? Please help my find out what i missed. Result: 0.0127289 0.0136499 0.0151598 0.0114031 0.014801 Answer To keep the loop
How do I find a system memory leak in linux?
I’ve got a monolithic piece of software, a game on a basic linux kernel, that seems to leak memory in swap space. The memory usage of the process itself is reported as constant over a day or so but the free memory on the system is consistently decreasing until there is no more physical ram space. There is no other
Do we need to unlocking a mutex after recived a signal from cond variable?
I making an app in C for educational purposes with mutexes and conditional variables. Short example here: Can you explain me, why after “while” statment (and recived signal from second thread) we need to unlock the mutex, when signal makes that mutex is locked? I get it from a lot examples from web, but when i want to work with
Cannot insert breakpoints. Addresses with low values
I’m trying to debug this simple C program: But when I disassemble the main function I get this: And this is already pretty strange because addresses starts with a prefix of 4… for 32 bit executables and 8… for 64 bit executables I think. But going on I then put a breakpoint: I run it and I get this error
Unnamed unix domain socket has wrong address length
When reading the address of a sending unix datagram domain socket in this minimal example program, I am getting an address length of 0, but the man page for unix domain sockets specifies that: unnamed: A stream socket that has not been bound to a pathname using bind(2) has no name. Likewise, the two sockets created by socket‐ pair(2) are