« first day (1313 days earlier)      last day (1544 days later) » 

user7659542
7:47 AM
How does it come that booleans are not atomic? At the end of the day it is just 1 single bit which tels the value
 
user7659542
I suppose you cannot be preempted while writing a single bit, ie true or false
 
user7659542
if it were a long and you are on a 32bit machine I'd understand as the data bus width is only 32 bits wide, you'd need 2 write operations and thus could be preempted between those two write ops
 
user7659542
I think...
 
8:02 AM
@traducerad atomicity is not just about reading/writing from a single thread, but also potentially across processor-cores. So it is also about cache-coherency
 
user7659542
8:23 AM
I have the feeling that if you want cache coherency here, ie making sure two cores don't write at the same time. Locking is what I would do rather than using atomicity.
 
user7659542
using atomicity is good against preemption, but for sharing data I d use locking mechanisms
 
it's not just about two cores writing at the same time, it's about one core reading an old value while the other already wrote and read a newer value
 
user7659542
@PeterT that's (arguably) all about volatile, not atomicity
 
user7659542
writing simultanuously is avoided using locking. Preemption is avoided using atomicity. And caching stuff is solved by volatile.
 
user7659542
That's my understanding
 
10:40 AM
no, volatile only has effect for the compiler in that it cannot eliminate dead writes and reads, however making those writes and reads atomic is a step on top of that with additional costs
 
 
2 hours later…
12:26 PM
I want to monitor EDX value at certain address in real time through a loop without the application (a game) freezing. Is it even possible with debugapi?
 
depends on your definition of "without freezing"
I don't think it's possible without pausing the thread at least for a short span. That's the way things like conditional breakpoints or "watch points" do it afaik
In theory it might be possible with a kernel driver, but I don't know enough about those
 
you can change the code to jump to a location to make the test and then jump back
 
maybe a better solution is to inject dll
 
oh, right that's a smarter way to do conditional breakpoints
@EduardoM how does injecting a dll help?
 
code injection I mean
something like "auto assembler" in cheat engine
 
12:36 PM
yeah, that's basically what @ratchetfreak was suggesting
 
my goal is to read this value in edx in a loop while playing the game
 
but you'll still only get it at certain points, unless you want to literally patch all edx writes
reading a single register throughout all function calls seems useless though
 
yeah that's why I said "at certain address"
there's a instruction in this address that storage the value in edx
 
yeah that seems reasonable , I was misreading the "real time" part I guess
 
yeah, the primitive approach of just traversing the tree and passing the past nodes along the path seems easy enough
 
but its like record all the paths
then find subsets which add to 8
the second bit is hard
 
hard to do fast maybe, but just brute-forcing it doesn't seem all that hard
 
nwp
@traducerad One reason is because atomic implies other threads get to see changes which implies you can't just keep the variable in a register. Also you can't reorder atomics but you can reorder regular variables. You don't want to pay for atomics if you don't need to. Compilers optimize and don't execute code as written, so your usage of bools might get completely optimized out which is no good when you want to communicate between threads.
 
@traducerad because it can't be architecturally guaranteed in all implementations
@traducerad volatile does not do what you think it does
 
2:17 PM
hi could someone explain what this line
for(int i=0;b[i];i++)
b is a string
 
iterate over the string until you hit a null character '\0'
strings are oftern null terminated, that means they mark their end with a null character after the last character that is part of the string
 
it's also a potential security vulnerability if the source of the string is not tightly controlled and verified to be null terminated
 
2:52 PM
what do you guys think of that one. just seems impossibly hard
 
nwp
3:06 PM
@Permian If you write the numbers down in binary you might see a trick. I don't know what the trick is, but basically you're looking for 1 big number and another number filling in the "holes" where the big number has 0s.
 
3:19 PM
@nwp still don't see how exactly one might do O(n), I can only think of an approximate answer in O(n)
 
nwp
3:30 PM
I can't find a solution either. Would need to actually write stuff down.
And ... just when I say that ... what if you radix-sort the elements first and then ... somehow linear search down to fill the holes. I don't know. Something like that should be the solution.
 
if only 1 number has the highest bit set then there is a trivial solution, but otherwise I can think of several scenarios where only a single pair is valid but any algorithm that doesn't check all pairs gets trapped
 
4:11 PM
Hi, I program a hangman game. I already have a (somewhat) working program but it contained some beginner mistakes and was a one file .cpp (+ a wordlist.txt). I saw this: codereview.stackexchange.com/questions/217671/… and wonder where can I learn the basics of mutifile programming, such that the int main() of the main.cpp looks like his. Is it even the suggested style?
 
4:45 PM
time to learn how the C++ build system fits together
each source file given to the compiler is considered a single translation unit, it can #include headers (often containing function declarations and data definitions)
and outputs an object file
then the linker gets all object files (and static libraries) and links them together into an executable (or dynamic library)
 
5:43 PM
@nwp i dont even understand the solution lol
 
6:30 PM
am just stupid? i have read that so many times and still dont get it
 
 
1 hour later…
7:31 PM
I have a struct called “Code” and I’m trying to store a reference to it so I don’t have to spell out its full path, but can’t seem to do so.
I did Code *saved = &info->values[i].code;
Instead of typing out info->values[i].code a hundred times, I’d just like to type saved->...
However, if I change a struct member using saved->name = ..., it changes the value for that variable only, not info->values[i].code.name
How can I get the actual reference in order to do the above?
 
 
4 hours later…
11:40 PM
@nwp O(N) is easy if it is ints. If the numbers are unbounded it is trickier.
 

« first day (1313 days earlier)      last day (1544 days later) »