[PATCH 3/3] libblock: Use beacon instead of events
Gedare Bloom
gedare at rtems.org
Tue Oct 16 16:21:49 UTC 2012
So this is a use-case for beacons... Can you provide a little more
info about why the beacon implements these requests better than
events? Will there be interference problems when users utilize
beacons?
-Gedare
On Tue, Oct 16, 2012 at 10:45 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> The usage of events for transfer and synchronization requests is bad
> because this may interfere with the event usage of application tasks.
> Typical errors result in stack corruption.
> ---
> cpukit/libblock/src/bdbuf.c | 27 ++++++++++++++++++++++-----
> 1 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c
> index 3f4915b..70c7ba0 100644
> --- a/cpukit/libblock/src/bdbuf.c
> +++ b/cpukit/libblock/src/bdbuf.c
> @@ -181,12 +181,13 @@ typedef struct rtems_bdbuf_cache
> #define RTEMS_BLKDEV_FATAL_BDBUF_STATE_1 RTEMS_BLKDEV_FATAL_ERROR(29)
> #define RTEMS_BLKDEV_FATAL_BDBUF_STATE_2 RTEMS_BLKDEV_FATAL_ERROR(30)
> #define RTEMS_BLKDEV_FATAL_BDBUF_RA_WAKE_UP RTEMS_BLKDEV_FATAL_ERROR(31)
> +#define RTEMS_BLKDEV_FATAL_BDBUF_WATCH_BEACON RTEMS_BLKDEV_FATAL_ERROR(32)
> +#define RTEMS_BLKDEV_FATAL_BDBUF_CLEAR_BEACON RTEMS_BLKDEV_FATAL_ERROR(33)
>
> /**
> * The events used in this code. These should be system events rather than
> * application events.
> */
> -#define RTEMS_BDBUF_TRANSFER_SYNC RTEMS_EVENT_1
> #define RTEMS_BDBUF_SWAPOUT_SYNC RTEMS_EVENT_2
> #define RTEMS_BDBUF_READ_AHEAD_WAKE_UP RTEMS_EVENT_1
>
> @@ -1549,6 +1550,22 @@ rtems_bdbuf_wait_for_event (rtems_event_set event)
> }
>
> static void
> +rtems_bdbuf_wait_for_beacon (rtems_id *task_id)
> +{
> + rtems_status_code sc = RTEMS_SUCCESSFUL;
> +
> + sc = rtems_beacon_watch (RTEMS_WAIT, RTEMS_NO_TIMEOUT);
> + if (sc != RTEMS_SUCCESSFUL)
> + rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_WATCH_BEACON);
> +
> + *task_id = 0;
> +
> + sc = rtems_beacon_clear ();
> + if (sc != RTEMS_SUCCESSFUL)
> + rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_CLEAR_BEACON);
> +}
> +
> +static void
> rtems_bdbuf_wait_for_access (rtems_bdbuf_buffer *bd)
> {
> while (true)
> @@ -1867,7 +1884,7 @@ rtems_bdbuf_transfer_done (void* arg, rtems_status_code status)
>
> req->status = status;
>
> - rtems_event_send (req->io_task, RTEMS_BDBUF_TRANSFER_SYNC);
> + rtems_beacon_signal (req->io_task);
> }
>
> static rtems_status_code
> @@ -1888,7 +1905,7 @@ rtems_bdbuf_execute_transfer_request (rtems_disk_device *dd,
>
> if (result == 0)
> {
> - rtems_bdbuf_wait_for_event (RTEMS_BDBUF_TRANSFER_SYNC);
> + rtems_bdbuf_wait_for_beacon (&req->io_task);
> sc = req->status;
> }
> else
> @@ -2268,7 +2285,7 @@ rtems_bdbuf_syncdev (rtems_disk_device *dd)
>
> rtems_bdbuf_wake_swapper ();
> rtems_bdbuf_unlock_cache ();
> - rtems_bdbuf_wait_for_event (RTEMS_BDBUF_TRANSFER_SYNC);
> + rtems_bdbuf_wait_for_beacon (&bdbuf_cache.sync_requester);
> rtems_bdbuf_unlock_sync ();
>
> return RTEMS_SUCCESSFUL;
> @@ -2617,7 +2634,7 @@ rtems_bdbuf_swapout_processing (unsigned long timer_delta,
> bdbuf_cache.sync_requester = 0;
> rtems_bdbuf_unlock_cache ();
> if (sync_requester)
> - rtems_event_send (sync_requester, RTEMS_BDBUF_TRANSFER_SYNC);
> + rtems_beacon_signal (sync_requester);
> }
>
> return transfered_buffers;
> --
> 1.7.7
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list