mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:39:44 +08:00
fs_inode:Change the type of i_crefs to atomic_int
Summary: 1.Modified the i_crefs from int16_t to atomic_int 2.Modified the i_crefs add, delete, read, and initialize interfaces to atomic operations The purpose of this change is to avoid deadlock in cross-core scenarios, where A Core blocks B Core’s request for a write operation to A Core when A Core requests a read operation to B Core. Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
+2
-2
@@ -74,7 +74,7 @@ static int nxmq_file_close(FAR struct file *filep)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
|
||||
if (inode->i_crefs <= 0)
|
||||
if (atomic_load(&inode->i_crefs) <= 0)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq = inode->i_private;
|
||||
|
||||
@@ -322,7 +322,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
|
||||
|
||||
/* Set the initial reference count on this inode to one */
|
||||
|
||||
inode->i_crefs++;
|
||||
atomic_fetch_add(&inode->i_crefs, 1);
|
||||
|
||||
if (created)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
static void mq_inode_release(FAR struct inode *inode)
|
||||
{
|
||||
if (inode->i_crefs <= 1)
|
||||
if (atomic_load(&inode->i_crefs) <= 1)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq = inode->i_private;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user