A race-cure case study a look at how some standard software tools can illuminate what is happening inside Linux. It includes Linux’s solution, 'LXR’ can help, ‘objdump’ can disassemble, Use a text-editor, Role of segmentation. | A race-cure case study A look at how some standard software tools can illuminate what is happening inside Linux Our recent ‘race’ example • Our ‘’ device-driver included a ‘race condition’ in its ‘read()’ and ‘write()’ functions, since accessing any CMOS memory-location is a two-step operation, and thus is a ‘critical section’ in our code: outb( reg_id, 0x70 ); datum = inb( 0x71 ); • Once the first step in this sequence is taken, the second step needs to follow No interventions! • To guarantee the integrity of each access to CMOS memory, we must prohibit every possibility that another control-thread may intervene and access that same i/o-port • The main ways in which an intervention by another ‘thread’ might happen are: – The current CPU could get ‘interrupted’; or – Another CPU could access the same i/o-port Linux’s solution • Linux provides a function that an LKM can call which is designed to insure ‘exclusive access’ to a CMOS memory-location: datum = rtc_cmos_read( reg_id ); • By using this function, a programmer does not have to expend time and mental effort analyzing the race-condition and devising a suitable ‘cure’ for it But how does it work? • As computer science students, we are not satisfied with just using convenient ‘blackbox’ solutions which we don’t understand • Such purported ‘solutions’ may not always accomplish everything that they claim – if they perform correctly today, they still may fail in some way in the future (if hardware changes); we don’t want to be .