[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 13 June 2002 11:04, Lo'oRiS il Kabukimono wrote:
> there are simple tricks to eat all the cpu (busy-wait)
Yes, but Linux (unlike non-NT Windows) has a preemptive multitasking
kernel. This means that a busy-waiting app can be preempted, and the
CPU given to another process.
Current fbdev implementations of 'vsync()' cause busy waiting *in the
kernel* -- this cannot be preempted, and so no other apps get the CPU
between a call to vsync() and the next retrace, at which point the CPU
must be given back to the app calling vsync() because that is the whole
point of waiting for the retrace!
A malicious program, therefore:
#include <allegro.h>
int main(void)
{
allegro_init();
set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
while(1) vsync();
}
This would pretty much stop the system instantly, and cannot be guarded
against. Not good if this can be run as a normal user.
Bye for now,
- --
Laurence Withers, lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9CJ0IUdhclgSmRuoRAhXtAJ4l+GMLnsBoemvPS4Kckft4qGY/ZQCgkrrX
m20oKjvijt9liDBNm8zMNas=
=LzoU
-----END PGP SIGNATURE-----