GIGJ.COM
welcome to my space
X
Personal Injury | Languages | Soups | Photography | Email | Prepress | Exotic Locations | Computer Games | Related articles
Welcome to:gigj.com
Search:  
NAVIGATION: Home >>
embedded system--interrupts
Published by: mike 2010-03-12

  • int iQueue[100]; int iHead=0; int iTail=0; void interrupt SourceInterrupt(void) { if((iHead+1==Tail)(iHead==99 && iTail==0)) { ++iTail; if(iTail==100) iTail=0; } iQueue[iHead]= !!next value ++iHead; if(iHead==100) iHead==0; } void SinkTask(void) { int iValue; while(TRUE) if(iTail!=iHead) { iValue=iQueue[iTail]; ++iTail; if(iTail==100) iTail=0; !! Do something with iValue; } } Question: in this code, it is a queuing functions without disabling interrupts, even assuming that all of the writes to the variables are atomic, a very nasty bug is hiding in this program , what is it?


  • Thank you for this question. Concurrency related issues are tricky but fun to think about. Here is one bug that can occur: Suppose that at the beginning of SinkTask iHead is 98 and iTail is 99. Now suppose the code executes "++iTail" in SinkTask when two interrupts are received. Thus, when the first interrupt is received and SourceInterrupt is executed, iHead is 98 and iTail is 100 . The "if" body in SouceInterrupt is not evaluated and subsequently iHead will be 99 and iTail will remain at 100. Now the second interrupt occurs, so that SourceInterrupt is called with iHead of 99 and iTail of 100. The body of the "if" statement in SourceInterrupt is now executed (since iHead+1==iTail), but iTail will be set to 101 by the body of the if statement in Source Interrupt. Subsequently, iTail will simply keep increasing without limit, and SinkTask will start getting garbage data or memory access violation when it tries: iValue=iQueue[iTail]
  • 00_Prelims-Embedded Systems.p65::
    File Format: PDF/Adobe Acrobat - View as HTML1.6 Embedded System-on-chip (Soc) and Use of VLSI Circuit Design Technology 29 4.1 programmed-I/O Busy-wait Approach without Interrupt Service Mechanism
    http://highered.mcgraw-hill.com/sites/dl/free/0070667640/607543/Detailed_Table_of_Contents.pdf
    HOME



    Nortel Unveils Vision, Strategy for Israeli High-Performance Net
    Busy Friday Leads to Strong Close for Net Stocks

  • contact for livs chrochet boots
  • retail price for electricity
  • pricing and suppliers for pyridine c5h5n
  • animal fats volumes in europe
  • winamp plug in needed log all files played
  • cheapest shopping bag suppliers
  • artist of nun painting
  • artist search 39 dubsky 39 surrealist
  • i decreased the font size on gmail com yahoo com among other web sites
  • 1 3 propanediol
  • pricing and suppliers for zinc sulfate
  • art of nikola
  • world 39 s largest art gallery
  • art artist identification

  • benny hill
  • diesel stations in utah and colorado
  • propylene pricing
  • very upscale short term rental accommodation
  • what defines a series for an artist
  • packaging machinery market sizes
  • giacometti 39 s sculptures
  • 20th century painters
  • pattern to make a russian fur hat ushanka
  • chagall lithographs real or fake
  • paper boy song source
  • hydrogen
  • prianesi prints
  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about embedded system--interrupts , Please add it free.
     Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 gigj.com        Site made:CFZ