qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [PATCH 11/19] use a bottom half to run timers


From: Jamie Lokier
Subject: Re: [Qemu-devel] Re: [PATCH 11/19] use a bottom half to run timers
Date: Wed, 6 Jan 2010 01:20:10 +0000
User-agent: Mutt/1.5.13 (2006-08-11)

Anthony Liguori wrote:
> Thread and signal safety are slightly different.

They are very different:

Virtually all libc calls are thread safe, unless they use unsafe
static data APIs.

On the other hand, the number of libc calls that are signal safe is
very limited.

For example, calling printf() is not signal-safe; neither is malloc().

pthread functions are not safe in signal handlers either:
pthread_self, pthread_getspecific, pthread_mutex_lock and
pthread_cond_broadcast, not of them are signal-safe.

In a nutshell, it's dubious to do much inside a signal handler.

Pure system calls tend to be ok, though.

> Scheduling an idle 
> callback from a signal handler is a pretty reasonable thing to do.

Scheduling, yes, by telling the main event loop that it's time.

Running it inside the signal handler... Then you're depending on
non-portabilities among hosts.

-- Jamie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]