[DGD] Another mudlib requirement

Steve Wooster swooster at xprt.net
Sat Feb 14 10:38:18 CET 2004


At 12:33 AM 2/14/2004 +0100, you wrote:
>The latter will probably modify the object, and if it commits before
>any of the callout-adding threads, they will be cancelled because
>they accessed a version of the object's state which is now out of
>date.

     This caused me to wonder something... if I wrote a thread that took an 
insane amount of CPU, and therefore a really long amount of time to 
complete, would it be possible that it might end up getting postponed 
indefinitely? For example: (assume this object has infinite rlimits)

int data;

void create()
{
     call_out("heart_beat",1);
     call_out("cpu_intensive_func",0);
}

void heart_beat()
{
     data=1;
     call_out("heart_beat",1);
}

void cpu_intensive_func()
{
     /*
     Insert code here with the following properties:
         the code doesn't access data
         the code takes about two seconds to complete
     */
     data=1;
}

Is it possible that cpu_intensive_func() may never get called? (because 
heart_beat() always commits before cpu_intensive_func() ever accesses data, 
so by the time cpu_intensive_func accesses data, it'll always need to be 
rescheduled)

If this is the case, could it be fixed by having cpu_intensive_data() 
modify data on the first line?

Thanks for any response. :)

-Steve Wooster

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list