sys/kern: Add lockmgr support

- See `man lockmgr`

- Implement the lock_object and move the RTEMS mutex to that object

- Add debug support to track the locks with gdb

Update #4475
This commit is contained in:
Chris Johns
2021-07-20 16:24:54 +10:00
parent e1ca99b535
commit 46a15fa7aa
17 changed files with 727 additions and 83 deletions

View File

@@ -74,9 +74,7 @@ struct lock_class *lock_classes[LOCK_CLASS_MAX + 1] = {
&lock_class_rm_sleepable,
#endif /* __rtems__ */
&lock_class_rw,
#ifndef __rtems__
&lock_class_lockmgr,
#endif /* __rtems__ */
};
void

View File

@@ -32,15 +32,23 @@
#ifndef _SYS__LOCK_H_
#define _SYS__LOCK_H_
#ifdef __rtems__
#include <machine/rtems-bsd-mutex.h>
#endif /* __rtems__ */
struct lock_object {
#ifndef __rtems__
const char *lo_name; /* Individual lock name. */
#else /* __rtems__ */
#define lo_name lo_mtx.queue.Queue.name
#endif /* __rtems__ */
u_int lo_flags;
#ifndef __rtems__
u_int lo_data; /* General class specific data. */
struct witness *lo_witness; /* Data for witness. */
#else /* __rtems__ */
unsigned int lo_flags;
#define lo_data lo_mtx.nest_level
rtems_bsd_mutex lo_mtx;
#endif /* __rtems__ */
};

View File

@@ -34,7 +34,9 @@
#define _SYS__LOCKMGR_H_
#ifdef DEBUG_LOCKS
#ifndef __rtems__
#include <sys/_stack.h>
#endif /* __rtems__ */
#endif
struct lock {
@@ -44,7 +46,11 @@ struct lock {
int lk_timo;
int lk_pri;
#ifdef DEBUG_LOCKS
#ifndef __rtems__
struct stack lk_stack;
#else /* __rtems__ */
void* lk_stack;
#endif /* __rtems__ */
#endif
};

View File

@@ -32,9 +32,6 @@
#ifndef _SYS__MUTEX_H_
#define _SYS__MUTEX_H_
#ifdef __rtems__
#include <machine/rtems-bsd-mutex.h>
#endif /* __rtems__ */
#include <machine/param.h>
@@ -51,8 +48,6 @@ struct mtx {
struct lock_object lock_object; /* Common lock properties. */
#ifndef __rtems__
volatile uintptr_t mtx_lock; /* Owner and flags. */
#else /* __rtems__ */
rtems_bsd_mutex mutex;
#endif /* __rtems__ */
};

View File

@@ -30,9 +30,6 @@
#ifndef _SYS__RWLOCK_H_
#define _SYS__RWLOCK_H_
#ifdef __rtems__
#include <machine/rtems-bsd-mutex.h>
#endif /* __rtems__ */
#include <machine/param.h>
@@ -49,8 +46,6 @@ struct rwlock {
struct lock_object lock_object;
#ifndef __rtems__
volatile uintptr_t rw_lock;
#else /* __rtems__ */
rtems_bsd_mutex mutex;
#endif /* __rtems__ */
};

View File

@@ -32,9 +32,6 @@
#ifndef _SYS__SX_H_
#define _SYS__SX_H_
#ifdef __rtems__
#include <machine/rtems-bsd-mutex.h>
#endif /* __rtems__ */
/*
* Shared/exclusive lock main structure definition.
@@ -43,8 +40,6 @@ struct sx {
struct lock_object lock_object;
#ifndef __rtems__
volatile uintptr_t sx_lock;
#else /* __rtems__ */
rtems_bsd_mutex mutex;
#endif /* __rtems__ */
};