Re: How to design non blocking device drivers?



Hans-Bernhard Bröker wrote:
ssubbarayan wrote:
complete the writing.What would be the way to design the driver in
such a way that the second task mentioned above does not go into
blocking,but still completes writing to the EEPROM.

That would be the impossible way. You have only one EEPROM, and one EEPROM can only do one write job at a time. So task2 cannot write to the EEPROM while task1 is still doing so. That leaves three possibilities:

1) fail: refuse the write job and return an error condition
2) block: wait for the other task, write, then finish successfully
3) cache: store the write's data and report success, although it hasn't actually been written to EEPROM yet

One can also mix these, e.g. block for a while, but fail if it takes too long. But your requirement to complete writing excludes 3) and 1), and you explicitly excluded 2), which leaves you with no way to do the job.

You can also send your write requests through a queue
to a task whose job it is to do the actual writing.

There are many ways of signalling the end of the writing
through events or another queue.

The posting task can mark the operation as 'in wait'
until it receives the notification. It can wait upon
it or test it regularly. All that is well known and
is called asynchronous operations.
.



Relevant Pages

  • Re: EEPROM guarantees after power loss during a write
    ... David Brown writes: ... My only worry was getting atleast one good copy.In your whole ... For any possible algorithm, if the power fails during writing of data, ... Assuming your eeprom is initially filled with 0xff, ...
    (comp.arch.embedded)
  • Re: EEPROM guarantees after power loss during a write
    ... My only worry was getting atleast one good copy.In your whole ... For any possible algorithm, if the power fails during writing of data, ... External serial eeproms generally have protection against this, but Atmel AVRs are known to be able to corrupt byte 0 of the eeprom if they get a reset during a write. ...
    (comp.arch.embedded)
  • Re: Writing to EEPROM
    ... I will be using internal EEprom - 512bytes. ... How many bytes will you be writing?. ... before the processor stops working (normally if the brownout is at ... How low can you get the power consumption ...
    (sci.electronics.design)
  • Re: Writing a serial number to EEPROM...
    ... data to the EEPROM. ... tells the Cypress chip to write to EEPROM and how to do it. ... so I wasn't writing to the EEPROM. ... upload the new binary file to the FX2 EEPROM. ...
    (comp.arch.embedded)
  • Re: How to design non blocking device drivers?
    ... You have only one EEPROM, and one EEPROM can only do one write job at a time. ... store the write's data and report success, although it hasn't actually been written to EEPROM yet ... But your requirement to complete writing excludes 3) and 1), and you explicitly excluded 2), which leaves you with no way to do the job. ...
    (comp.arch.embedded)