Thread: MIPS synchronisation (ll/sc)

  1. #1
    Registered User
    Join Date
    Sep 2011
    Location
    Hong Kong
    Posts
    18

    MIPS synchronisation (ll/sc)

    I wanted to know that if while using ll/sc there is a change in processor before the sc statement is executed what would be result.

    E.g.

    CPU 1 ==> $t1 = 1, $t0 = 2
    CPU 2 ==> $t1 = 30, $t0 = 40
    MEMORY ==> $s0 = 99

    If we execute these statements:


    Code:
    ll $t1, 0($s0)     --- CPU 1
    ll $t1, 0($s0)   --- CPU 2
    addi $t1, $t1, 1   --- CPU 2
    sc $t1, 0($s0)   --- CPU 2 ($t1 = 1, $s0 = 100)
    sc $t0, 0($s0)   --- CPU 1
    I know that after the execution (Correct me if I am wrong):

    CPU 2 ==> $t1 = 1, $t0 = 40
    CPU 1 ==> $t1 = 99

    I don't know what will happen to $s0 and $t0 after the CPU 1 command. Will $s0 = 2 ??
    Last edited by stud91; 02-11-2012 at 10:21 AM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    From a random MIPS assembly doc that Google found for me - it says that the source register is set to 0 when SC fails, and 1 when it succeeds.

    So if line 4 succeeds, then $t1 = 1 and $s0 = 100.

    Then line 5 will fail (because $s0 has now been modified since the LL on line 1), so $t0 = 0, and $s0 is still 100 (unless something else has since modified the memory at $s0).

    >> Will $s0 = 2 ??
    No. A failed SC does not modify memory.

    gg

  3. #3
    Registered User
    Join Date
    Sep 2011
    Location
    Hong Kong
    Posts
    18
    Thanks a lot for your reply... I also found that random MIPS assembly doc

    Here it is:
    http://www.weblearn.hs-bremen.de/ris...S/mips-isa.pdf

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Posix threads synchronisation with semaphores
    By evariste in forum C Programming
    Replies: 6
    Last Post: 10-26-2010, 03:41 PM
  2. Replies: 5
    Last Post: 10-17-2008, 11:28 AM
  3. C# Multithreading Synchronisation
    By Welshy in forum C# Programming
    Replies: 0
    Last Post: 04-21-2007, 11:24 AM
  4. Registry synchronisation
    By Magos in forum Windows Programming
    Replies: 1
    Last Post: 03-18-2006, 12:35 AM
  5. Threads, synchronisation and temporary files
    By Magos in forum Windows Programming
    Replies: 3
    Last Post: 03-03-2005, 05:01 PM