I have a program and I want to measure its execution (wallclock) time for different input sizes. In some other similar questions I read that using clock_gettime in the source code wouldn’t be reliable because of the CPUs branch predictor, register renaming, speculative execution, out-of-order execution …
Tag: c++
where is file descriptor stored in process memory?
When a function A is called from a point of execution, internally it is a JMP statement to the address pointing to function A. So the current point of execution is saved onto the stack, the PC loads the address of the called function A and continues. To get back to the point of execution after the function ca…
Be confused with msg_name field in msghdr structure
In user space, I encapsulated a L3 packet using sock_raw (including IP header) and send to kernel space using sock_sendmsg() using msghdr structure I cannot understand clearly the roles of msg_name. I already specified the source IP and dest IP in L3 header. Why do I need msg_name? Answer The msg_name and msg…
Why would this image threshold work in windows but not mono / linux?
I have a relatively simple threshold function that’s using unsafe code. This works a treat in Windows, however, in Mono on linux, no thresholding takes place. It’s difficult to debug as it’s on Linux only, I’ve checked the bitsPerPixel is correct along with the height h, width w and st…
pthread is faster than serial in Windows but slower than serial in Linux
I am trying to run the same C++ parallel code to calculated pi with Monte Carlo algorithm on Windows and Linux with the same number of threads (4 threads with 4 CPUs). While the parallel code is faster than the serial implementation on Windows, it is much slower on Linux. Here is the program: output on Window…
Why sem_t pointer have to start at multiple of 4 offset?
When you accessing block of memory (f.e. in real case using mmap) correct pointer for sem_t have to by multiple of 4. If it is not, then sem_init() still doesn’t return -1 (error value), but sem_t isn’t valid. Why it is working like this? Below code that is showing behaviour of semaphores. Answer …
Select() to read in sockets
I have a client server client connection where the server reads the message sent by the client every 1 second but I do not want the server to keep on waiting for a message for too long. I tried using the select() function but the server continues waiting for some message to read. Could anyone tell me what I a…
Random mmaped memory access up to 16% slower than heap data access
Our software builds a data structure in memory that is about 80 gigabytes large. It can then either use this data structure directly to do its computation, or dump it to disk so it can be reused several times afterwards. A lot of random memory accesses happens in this data structure. For larger input this dat…
Linux server C code stalls after receiving a signal
I have a problem with this simple server code, it works as expected until it receives a signal. For debug I print server and client file descriptors before calling select with the line: When running normally it keeps printing but when it receives a signal it prints this line once and then the program stalls. …
What does it means to have a capability only in the inheritable set?
My program is being run with cap_sys_admin,cap_setgid+i. Of course, I understand that they are inheritable across execve, but beside that : does they behave the same way as if I don’t have them at all since they are neither effective nor permitted? Answer OK so your process is running with some Inheritable ca…