Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Threading, without threading?

Name: Anonymous 2012-08-07 15:58

Allow me to explain:

int x;
int y;

void inc_x() { x++; }
void inc_y() { y++; }

int  get_x() { return x; }

int main() {
    int i;

    for( i = 0; i < 10; i++ ) {
        inc_x();
        inc_y(); // executed after inc_x(), but why wait?
                 // why not execute inc_y() in a separate thread?
                 // So, is this 'automatic threading' been done before?
                 // Is it even possible?
    }

    return get_x();
}

Name: Anonymous 2012-08-07 18:15

>>1
The implementation has to behave ``as if'' they happened in order they would on the abstract machine. If there's no way for the program to ``observe'' a discrepancy without resorting to undefined behavior, they can take place simultaneously.
>>4
Global/static variables in C are initialized to zero. Nice tryoll though.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List