<div class="gmail_quote">On Wed, Feb 2, 2011 at 12:58 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com">mathias.krause@secunet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 01.02.2011 22:37, David Hendricks wrote:<br>
> Hi,<br>
> I have attached a patch which adds a locking mechanism to Flashrom to<br>
> prevent multiple instances from running simultaneously. It may need some<br>
> modification to fit different Flashrom use cases better, but I think<br>
> it's a good start.<br>
<br>
</div>Nice </blockquote><div><br></div><div>Thanks!</div><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>On Wed, Feb 2, 2011 at 12:58 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com">mathias.krause@secunet.com</a>></span> wrote: </div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">.> The size of the patch is somewhat misleading -- The only real changes to<div class="im">
> Flashrom's current code are some of the exit points in cli_classic() and<br>
> some added stuff in the Makefile. Everything else is contained in new<br>
> files. The new files are:<br>
> csem.{c,h}: Low-level code that interfaces with semctl(), semget(), etc.<br>
> ipc_lock.{c,h}: Wrapper for csem stuff.<br>
> locks.h: A listing of locks that Flashrom cares about.<br>
> big_lock.{c,h}: An even higher-level wrapper around ipc_lock stuff,<br>
> useful for simple, coarse-grained locking.<br>
<br>
</div>Well, quite some wrapping wrappers :/<br></blockquote><div><br></div><div>Agreed, to a point. The ipc_lock stuff is a useful abstraction. The big_lock stuff is just there to emphasize the notion of a single lock used for multiple programs -- It's just a trivial wrapper for handling a single lock.</div>

<div><br></div><div>From Flashrom's perspective this probably isn't very useful. Perhaps that's reason enough to omit it. It's mostly just there to help coordinate between different programs (ie for distro maintainers).</div>

<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8">On Wed, Feb 2, 2011 at 12:58 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com">mathias.krause@secunet.com</a>></span> wrote:</div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
> util/use_big_lock.sh: Used by the Makefile to test for POSIX.1-2001<br>
> compliance.<br>
<br>
</div>That test should be integrated into the Makefile, no?<br></blockquote><div><br></div><div>Maybe. I spent some time trying to do that but my result came out fugly.</div><div><br></div><div>IIRC the hard part was trying to define a macro based on the result of the command. The other tests do the opposite -- They use an existing macro to determine whether to run a test. Someone with stronger Make-fu is welcome to show me how this is done :-)</div>

<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8">On Wed, Feb 2, 2011 at 12:58 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com">mathias.krause@secunet.com</a>></span> wrote:</div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Otherwise this code looks good to me, albeit a little bit bloated for<br>
just such little functionality. Anyway, Carl-Daniel should comment on this.<br></blockquote><div><br></div><div>Fair enough. I feel it's useful and wanted to get this upstreamed to reduce diffs w/ Chromium OS. But it is pretty heavy-weight for what might not be important to the upstream flashrom community at this time.</div>

<div><br></div><div>To illustrate our usage case, on Chrome OS devices* we have multiple programs that access the ROM. Our auto-updater uses these programs in the background. We've already been bitten by developers attempting to manually update/reflash their BIOS and/or EC firmware while the auto-updater is attempting to do stuff. ECs can be especially troublesome since they often access their ROM constantly and will crash if you corrupt the ROM, unlike most x86 BIOSes where you at least stand a chance to recover.</div>

<meta http-equiv="content-type" content="text/html; charset=utf-8"></div><div><br></div>*Chrome OS is tailored for specific devices. Chromium OS is the more generic version that can be put on a broad range of hardware.<div>

<br>-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>
</div>