forked from Imagelibrary/rtems
score: Use allocator lock in _Objects_Get_next()
Use the object allocator lock in _Objects_Get_next() instead of disabled thread dispatching since object creation and deletion is covered by this lock. Update #2555.
This commit is contained in:
@@ -614,7 +614,10 @@ Objects_Control *_Objects_Get_no_protection(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like @ref _Objects_Get, but is used to find "next" open object.
|
* Like @ref _Objects_Get, but is used to find "next" open
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* Locks the object allocator mutex in case a next object exists.
|
||||||
*
|
*
|
||||||
* @param[in] information points to an object class information block.
|
* @param[in] information points to an object class information block.
|
||||||
* @param[in] id is the Id of the object whose name we are locating.
|
* @param[in] id is the Id of the object whose name we are locating.
|
||||||
|
|||||||
@@ -20,31 +20,6 @@
|
|||||||
|
|
||||||
#include <rtems/score/objectimpl.h>
|
#include <rtems/score/objectimpl.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* _Objects_Get_next
|
|
||||||
*
|
|
||||||
* Like _Objects_Get, but considers the 'id' as a "hint" and
|
|
||||||
* finds next valid one after that point.
|
|
||||||
* Mostly used for monitor and debug traversal of an object.
|
|
||||||
*
|
|
||||||
* Input parameters:
|
|
||||||
* information - pointer to entry in table for this class
|
|
||||||
* id - object id to search for
|
|
||||||
* location - address of where to store the location
|
|
||||||
* next_id - address to store next id to try
|
|
||||||
*
|
|
||||||
* Output parameters:
|
|
||||||
* returns - address of object if local
|
|
||||||
* location - one of the following:
|
|
||||||
* OBJECTS_ERROR - invalid object ID
|
|
||||||
* OBJECTS_REMOTE - remote object
|
|
||||||
* OBJECTS_LOCAL - local object
|
|
||||||
* next_id - will contain a reasonable "next" id to continue traversal
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* assumes can add '1' to an id to get to next index.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Objects_Control *
|
Objects_Control *
|
||||||
_Objects_Get_next(
|
_Objects_Get_next(
|
||||||
Objects_Information *information,
|
Objects_Information *information,
|
||||||
@@ -70,16 +45,20 @@ _Objects_Get_next(
|
|||||||
else
|
else
|
||||||
next_id = id;
|
next_id = id;
|
||||||
|
|
||||||
|
_Objects_Allocator_lock();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* walked off end of list? */
|
/* walked off end of list? */
|
||||||
if (_Objects_Get_index(next_id) > information->maximum)
|
if (_Objects_Get_index(next_id) > information->maximum)
|
||||||
{
|
{
|
||||||
|
_Objects_Allocator_unlock();
|
||||||
*location_p = OBJECTS_ERROR;
|
*location_p = OBJECTS_ERROR;
|
||||||
goto final;
|
*next_id_p = OBJECTS_ID_FINAL;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to grab one */
|
/* try to grab one */
|
||||||
object = _Objects_Get(information, next_id, location_p);
|
object = _Objects_Get_no_protection(information, next_id, location_p);
|
||||||
|
|
||||||
next_id++;
|
next_id++;
|
||||||
|
|
||||||
@@ -87,8 +66,4 @@ _Objects_Get_next(
|
|||||||
|
|
||||||
*next_id_p = next_id;
|
*next_id_p = next_id;
|
||||||
return object;
|
return object;
|
||||||
|
|
||||||
final:
|
|
||||||
*next_id_p = OBJECTS_ID_FINAL;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ int scan_objects(
|
|||||||
break;
|
break;
|
||||||
/* XXX check dispatch level with macros */
|
/* XXX check dispatch level with macros */
|
||||||
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
/* XXX should be able to check that next Id is not one we have seen */
|
/* XXX should be able to check that next Id is not one we have seen */
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
Reference in New Issue
Block a user