lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <AANLkTinocDQ1J4FR5JO_j7qwLKv1QYPvZ1Y4r+v44esi@mail.gmail.com>
Date:	Tue, 4 Jan 2011 22:18:49 +0800
From:	Hillf Danton <dhillf@...il.com>
To:	Pavel Machek <pavel@....cz>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v0] add nano semaphore in kernel

On Tue, Jan 4, 2011 at 10:03 PM, Pavel Machek <pavel@....cz> wrote:
> Hi!
>
>> +/*
>> + * nano_semaphore_down - acquire the nano semaphore
>> + * @s: the nano semaphore to be acquired
>> + * @nano_secs: the nano seconds to wait if necessary,
>> + *           could be zero if want to wait as long as possible.
>> + *
>> + * Returns >0 if acquired successfully, <=0 otherwise.
>> + *
>> + * Note unlike down() in semaphore, nano_semaphore_down is not looping until
>> + * the nano semaphore is hold, but simply reports the result. And the callers
>> + * could, if they like, loop in simple manner, for instance,
>> + *   while (1 != nano_semaphore_down(s, 800));
>> + *   do_home_work();
>> + *   nano_semaphore_up(s);
>
> But thats spinlock, not semaphore, right?
>

Though spin lock involved, the caller has to sleep 800ns per loop.

> Also, your example does not use the API right -- according to
> description, 42 is correct 'semaphore acquired' reply...
>

As I understand, the example, though could be totally removed, does
not show the recommended usage of nano semaphore, but expresses the
difference from semaphore. The recommended however looks

       nano_semaphore_down(s, 0);
       do_home_work();
       nano_semaphore_up(s);

if you like to wait as long as possible.

Cheers
Hillf
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ