Sebastian Huber 3b4ca3ab0f bdbuf: Fix race condition with sync active flag
Bug report by Oleg Kravtsov:

In rtems_bdbuf_swapout_processing() function there is the following
lines:

if (bdbuf_cache.sync_active && !transfered_buffers)
{

    rtems_id sync_requester;
    rtems_bdbuf_lock_cache ();
    ...

}

Here access to bdbuf_cache.sync_active is not protected with anything.
Imagine the following test case:

1. Task1 releases buffer(s) with bdbuf_release_modified() calls;

2. After a while swapout task starts and flushes all buffers;

3. In the end of that swapout flush we are before that part of code, and
assume there is task switching (just before "if (bdbuf_cache.sync_active
&& !transfered_buffers)");

4. Some other task (with higher priority) does bdbuf_release_modified
and rtems_bdbuf_syncdev().

This task successfully gets both locks sync and pool (in
rtems_bdbuf_syncdev() function), sets sync_active to true and starts
waiting for RTEMS_BDBUF_TRANSFER_SYNC event with only sync lock got.

5. Task switching happens again and we are again before "if
(bdbuf_cache.sync_active && !transfered_buffers)".

As the result we check sync_active and we come inside that "if"
statement.

6. The result is that we send RTEMS_BDBUF_TRANSFER_SYNC event! Though
ALL modified messages of that task are not flushed yet!

close #1485
2014-11-28 10:56:46 +01:00
2014-11-27 14:03:34 +01:00
2014-11-20 07:27:34 +11:00

This is the Real-Time Executive for Multiprocessing Systems (RTEMS).
The version number for this software is indicated in the VERSION file.

See the documentation manuals in doc/ with daily builds available online at
http://rtems.org/onlinedocs/doc-current/share/rtems/html/ and released builds
at http://www.rtems.org/onlinedocs/releases/ for information on building,
installing, and using RTEMS. The INSTALL file tells you to come back here.

See the RTEMS Wiki at http://wiki.rtems.org/wiki/index.php/Main_Page
for community knowledge and tutorials.

RTEMS Doxygen available at http://www.rtems.org/onlinedocs/doxygen/cpukit/html

Get help on the mailing lists:
* For general-purpose questions related to using RTEMS, use the
  rtems-users ml: http://www.rtems.org/mailman/listinfo/rtems-users
* For questions and discussion related to development of RTEMS, use the
  rtems-devel ml: http://www.rtems.org/mailman/listinfo/rtems-devel

See http://www.rtems.org/bugzilla/ to report a bug.

Description
RTEMS is a ​real-time executive in use by embedded systems applications around the world and beyond
Readme 126 MiB
Languages
C 93.9%
Assembly 3.4%
Ada 1.4%
Python 0.3%
HTML 0.3%
Other 0.4%