Skip to content

Commit

Permalink
Merge pull request #478 from jphickey/fix-476-global-mutex-wrapper
Browse files Browse the repository at this point in the history
Fix #476, add global lock/unlock wrapper
  • Loading branch information
jphickey committed May 27, 2020
2 parents 5f910f7 + 4ef9c18 commit 5c8a01c
Show file tree
Hide file tree
Showing 18 changed files with 265 additions and 88 deletions.
9 changes: 1 addition & 8 deletions src/os/posix/src/os-impl-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ int32 OS_Lock_Global_Impl(uint32 idtype)
POSIX_GlobalLock_t *mut;
sigset_t previous;

if (idtype < MUTEX_TABLE_SIZE)
{
mut = MUTEX_TABLE[idtype];
}
else
{
mut = NULL;
}
mut = MUTEX_TABLE[idtype];

if (mut == NULL)
{
Expand Down
23 changes: 21 additions & 2 deletions src/os/shared/inc/os-shared-idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ int32 OS_ObjectIdInit (void);


/*----------------------------------------------------------------
Function: OS_Lock_Global_Impl
Function: OS_Lock_Global
Purpose: Locks the global table identified by "idtype"
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
void OS_Lock_Global(uint32 idtype);

/*----------------------------------------------------------------
Function: OS_Lock_Global
Purpose: Locks the global table identified by "idtype"
Expand All @@ -111,7 +120,17 @@ int32 OS_ObjectIdInit (void);
int32 OS_Lock_Global_Impl(uint32 idtype);

/*----------------------------------------------------------------
Function: OS_Unlock_Global_Impl
Function: OS_Unlock_Global
Purpose: Unlocks the global table identified by "idtype"
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
void OS_Unlock_Global(uint32 idtype);


/*----------------------------------------------------------------
Function: OS_Unlock_Global
Purpose: Unlocks the global table identified by "idtype"
Expand Down
4 changes: 2 additions & 2 deletions src/os/shared/src/osapi-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int32 OS_BinSemDelete (uint32 sem_id)
record->active_id = 0;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -318,7 +318,7 @@ int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop)
strncpy(bin_prop->name, record->name_entry, OS_MAX_API_NAME - 1);
bin_prop->creator = record->creator;
return_code = OS_BinSemGetInfo_Impl (local_id, bin_prop);
OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down
4 changes: 2 additions & 2 deletions src/os/shared/src/osapi-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int32 OS_CountSemDelete (uint32 sem_id)
record->active_id = 0;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -288,7 +288,7 @@ int32 OS_CountSemGetInfo (uint32 sem_id, OS_count_sem_prop_t *count_prop)
count_prop->creator = record->creator;

return_code = OS_CountSemGetInfo_Impl (local_id, count_prop);
OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down
4 changes: 2 additions & 2 deletions src/os/shared/src/osapi-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int32 OS_DirectoryClose(uint32 dir_id)
record->active_id = 0;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -229,7 +229,7 @@ int32 OS_DirectoryRead(uint32 dir_id, os_dirent_t *dirent)
*/
return_code = OS_DirRead_Impl(local_id, dirent);

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down
20 changes: 10 additions & 10 deletions src/os/shared/src/osapi-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int32 OS_close (uint32 filedes)
record->active_id = 0;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -454,7 +454,7 @@ int32 OS_rename (const char *old, const char *new)

if (return_code == OS_SUCCESS)
{
OS_Lock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Lock_Global(LOCAL_OBJID_TYPE);
for ( i =0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
if (OS_global_stream_table[i].active_id != 0 &&
Expand All @@ -464,7 +464,7 @@ int32 OS_rename (const char *old, const char *new)
strcpy (OS_stream_table[i].stream_name, new);
}
}
OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -609,7 +609,7 @@ int32 OS_FDGetInfo (uint32 filedes, OS_file_prop_t *fd_prop)
strncpy(fd_prop->Path, record->name_entry, OS_MAX_PATH_LEN - 1);
fd_prop->User = record->creator;
fd_prop->IsValid = true;
OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

return return_code;
Expand Down Expand Up @@ -637,7 +637,7 @@ int32 OS_FileOpenCheck(const char *Filename)

return_code = OS_ERROR;

OS_Lock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Lock_Global(LOCAL_OBJID_TYPE);

for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
Expand All @@ -650,7 +650,7 @@ int32 OS_FileOpenCheck(const char *Filename)
}
}/* end for */

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);

return return_code;
} /* end OS_FileOpenCheck */
Expand Down Expand Up @@ -678,7 +678,7 @@ int32 OS_CloseFileByName(const char *Filename)

return_code = OS_FS_ERR_PATH_INVALID;

OS_Lock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Lock_Global(LOCAL_OBJID_TYPE);

for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
Expand All @@ -698,7 +698,7 @@ int32 OS_CloseFileByName(const char *Filename)
}
}/* end for */

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);

return (return_code);

Expand All @@ -721,7 +721,7 @@ int32 OS_CloseAllFiles(void)

return_code = OS_SUCCESS;

OS_Lock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Lock_Global(LOCAL_OBJID_TYPE);

for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
Expand All @@ -739,7 +739,7 @@ int32 OS_CloseAllFiles(void)
}
}/* end for */

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);

return (return_code);

Expand Down
22 changes: 11 additions & 11 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ int32 OS_rmfs (const char *devname)
global->active_id = 0;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}
else
{
Expand Down Expand Up @@ -685,7 +685,7 @@ int32 OS_mount (const char *devname, const char* mountpoint)
strcpy(local->virtual_mountpt, mountpoint);
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}


Expand Down Expand Up @@ -764,7 +764,7 @@ int32 OS_unmount (const char *mountpoint)
local->flags &= ~(OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL);
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}


Expand Down Expand Up @@ -811,7 +811,7 @@ int32 OS_fsBlocksFree (const char *name)

return_code = OS_FileSysStatVolume_Impl(local_id, &statfs);

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);

if (return_code == OS_SUCCESS)
{
Expand Down Expand Up @@ -863,7 +863,7 @@ int32 OS_fsBytesFree (const char *name, uint64 *bytes_free)

return_code = OS_FileSysStatVolume_Impl(local_id, &statfs);

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);

if (return_code == OS_SUCCESS)
{
Expand Down Expand Up @@ -974,7 +974,7 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, const char * MountPoint)
return_code = OS_ERR_INCORRECT_OBJ_STATE;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}
else
{
Expand Down Expand Up @@ -1012,7 +1012,7 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info)
filesys_info->MaxFds = OS_MAX_NUM_OPEN_FILES;
filesys_info->MaxVolumes = OS_MAX_FILE_SYSTEMS;

OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_STREAM);
OS_Lock_Global(OS_OBJECT_TYPE_OS_STREAM);

for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++ )
{
Expand All @@ -1022,9 +1022,9 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info)
}
}

OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_STREAM);
OS_Unlock_Global(OS_OBJECT_TYPE_OS_STREAM);

OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_FILESYS);
OS_Lock_Global(OS_OBJECT_TYPE_OS_FILESYS);

for ( i = 0; i < NUM_TABLE_ENTRIES; i++ )
{
Expand All @@ -1034,7 +1034,7 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info)
}
}

OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_FILESYS);
OS_Unlock_Global(OS_OBJECT_TYPE_OS_FILESYS);

return(OS_SUCCESS);
} /* end OS_GetFsInfo */
Expand Down Expand Up @@ -1128,7 +1128,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
return_code = OS_ERR_INCORRECT_OBJ_STATE;
}

OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE);
OS_Unlock_Global(LOCAL_OBJID_TYPE);
}

if (return_code == OS_SUCCESS)
Expand Down
Loading

0 comments on commit 5c8a01c

Please sign in to comment.