lkml.org 
[lkml]   [2001]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [Q] Implementation of spin_lock on i386: why "rep;nop" ?
    On Mon, 17 Sep 2001, Jean-Marc Saffroy wrote:

    > Hi all,
    >
    > One of my coworkers directed my attention to the implementation of
    > spinlocks on IA-32. In spin_lock_string, we can read:
    >
    > "cmpb $0,%0\n\t" \
    > "rep;nop\n\t" \
    > "jle 2b\n\t" \
    >
    > The "rep;nop" line looks dubious, since the IA-32 programmer's manual from
    > Intel (year 2001) mentions that the behaviour of REP is undefined when it
    > is not used with string opcodes. BTW, according to the same manual, REP is
    > supposed to modify ecx, but it looks like is is not the case here... which
    > is fortunate, since ecx is never saved. :-)
    >
    > What is the intent behind this "rep;nop" ? Does it really rely on an
    > undocumented behaviour ?
    >
    >
    > Regards,

    Well it's now documented although you have to search a web-site to
    find it. Basically, it runs the CPU at low clock-speed when it's
    busy-waiting. Since most all spin-locks lock for mere microseconds
    it's unlikely that it does anything useful, but it can't hurt.

    Cheers,
    Dick Johnson

    Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.


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

    \
     
     \ /
      Last update: 2005-03-22 13:03    [W:5.101 / U:0.120 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site