[Lxc-users] Is lxc-start threadsave?

Michael H. Warfield mhw at WittsEnd.com
Tue Jul 5 15:13:16 UTC 2011


On Tue, 2011-07-05 at 17:05 +0200, Jäkel, Guido wrote: 
> >> is lxc-start threadsave, i.e. may a start up different containers in
> >> parallel? Have I to apply a individual value for 'lxc.rootfs.mount',
> >> e.g. by use of the process id or 'mktemp'. Or something else, more?
> >
> >Ah, you're mixing apples and oranges here.  Starting up two containers
> >in parallel means you are running lxc-start twice and that's two full
> >heavy-weight processes, no threads required and nothing to do with
> >requiring threat-safe.
> 
> Your'e completely right, that 'thread-save' wasn't the right term. And
> of corse, booting a bunch of containers by sequential calls of
> lxc-start will take not significant more time than doing it in
> parallel -- because most of the lauch time is spend by the Linux
> bootstrapping.
> 
> But I want to know it for another reason: If I going to write
> automated scripts to lauch some containers, they might be called "at
> the same time" (in terms of the lauch time of lxc before forking the
> init). And therefore I ask if I have to avoid a possible race
> condition by any kind of semaphore or is it safe to lauch it more than
> one time.

Yeah, I do it all the time.  Your problem will not be race conditions
but it could be crushing your poor host if you try to do too many at
once.  You might want to stick a load average check in there just to
protect yourself.  If you don't want to hold up the boot process, fork
your main loop into the background and include the load average check
inside the main loop.

> Guido

Regards,
Mike
-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20110705/485fdd75/attachment.pgp>


More information about the lxc-users mailing list