summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/aio_misc.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-10 08:15:37 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-11 10:58:09 +0100
commitae88aa7927dbbfb7b841dee8133f55c38303b91b (patch)
tree2b2b447a0c4a7848fb493044453226f0ec883545 /cpukit/posix/src/aio_misc.c
parentprintk: Add support for long long (diff)
downloadrtems-ae88aa7927dbbfb7b841dee8133f55c38303b91b.tar.bz2
sapi: Use one SMP lock for all chains
This partially reverts commit 1215fd4d9426a59d568560e9a485628560363133. In order to support profiling of SMP locks and provide a future compatible SMP locks API it is necessary to add an SMP lock destroy function. Since the commit above adds an SMP lock to each chain control we would have to add a rtems_chain_destroy() function as well. This complicates the chain usage dramatically. Thus revert the patch above. A global SMP lock for all chains is used to implement the protected chain operations. Advantages: * The SAPI chain API is now identical on SMP and non-SMP configurations. * The size of the chain control is reduced and is then equal to the Score chains. * The protected chain operations work correctly on SMP. Disadvantage: * Applications using many different chains and the protected operations may notice lock contention. The chain control size drop is a huge benefit (SAPI chain controls are 66% larger than the Score chain controls). The only disadvantage is not really a problem since these applications can use specific interrupt locks and unprotected chain operations to avoid this issue.
Diffstat (limited to 'cpukit/posix/src/aio_misc.c')
-rw-r--r--cpukit/posix/src/aio_misc.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/cpukit/posix/src/aio_misc.c b/cpukit/posix/src/aio_misc.c
index 656ba41bab..36785739d4 100644
--- a/cpukit/posix/src/aio_misc.c
+++ b/cpukit/posix/src/aio_misc.c
@@ -120,9 +120,7 @@ rtems_aio_search_fd (rtems_chain_control *chain, int fildes, int create)
if (rtems_chain_is_empty (chain))
rtems_chain_prepend (chain, &r_chain->next_fd);
else
- rtems_chain_explicit_insert (chain,
- rtems_chain_previous (node),
- &r_chain->next_fd);
+ rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
r_chain->new_fd = 1;
r_chain->fildes = fildes;
@@ -159,9 +157,7 @@ rtems_aio_move_to_work (rtems_aio_request_chain *r_chain)
temp = (rtems_aio_request_chain *) node;
}
- rtems_chain_explicit_insert (work_req_chain,
- rtems_chain_previous (node),
- &r_chain->next_fd);
+ rtems_chain_insert (rtems_chain_previous (node), &r_chain->next_fd);
}
@@ -200,7 +196,7 @@ rtems_aio_insert_prio (rtems_chain_control *chain, rtems_aio_request *req)
prio = ((rtems_aio_request *) node)->aiocbp->aio_reqprio;
}
- rtems_chain_explicit_insert (chain, node->previous, &req->next_prio);
+ rtems_chain_insert (node->previous, &req->next_prio);
}
}
@@ -226,7 +222,7 @@ void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain)
while (!rtems_chain_is_tail (chain, node))
{
- rtems_chain_explicit_extract (chain, node);
+ rtems_chain_extract (node);
rtems_aio_request *req = (rtems_aio_request *) node;
node = rtems_chain_next (node);
req->aiocbp->error_code = ECANCELED;
@@ -270,7 +266,7 @@ int rtems_aio_remove_req (rtems_chain_control *chain, struct aiocb *aiocbp)
return AIO_NOTCANCELED;
else
{
- rtems_chain_explicit_extract (chain, node);
+ rtems_chain_extract (node);
current->aiocbp->error_code = ECANCELED;
current->aiocbp->return_value = -1;
free (current);
@@ -445,7 +441,7 @@ rtems_aio_handle (void *arg)
param.sched_priority = req->priority;
pthread_setschedparam (pthread_self(), req->policy, &param);
- rtems_chain_explicit_extract (chain, node);
+ rtems_chain_extract (node);
pthread_mutex_unlock (&r_chain->mutex);
@@ -511,8 +507,7 @@ rtems_aio_handle (void *arg)
/* If no requests were added to the chain we delete the fd chain from
the queue and start working with idle fd chains */
if (result == ETIMEDOUT) {
- rtems_chain_explicit_extract (&aio_request_queue.work_req,
- &r_chain->next_fd);
+ rtems_chain_extract (&r_chain->next_fd);
pthread_mutex_destroy (&r_chain->mutex);
pthread_cond_destroy (&r_chain->cond);
free (r_chain);
@@ -548,7 +543,7 @@ rtems_aio_handle (void *arg)
++aio_request_queue.active_threads;
node = rtems_chain_first (&aio_request_queue.idle_req);
- rtems_chain_explicit_extract (&aio_request_queue.idle_req, node);
+ rtems_chain_extract (node);
r_chain = (rtems_aio_request_chain *) node;
rtems_aio_move_to_work (r_chain);