added reenter check to lock_dequeue() to avoid unlocking of interrupts
via cause_sig() during an exception. moved lock check configuration to <minix/sys_config.h> instead of kernel/config.h, because the 'relocking' field in kinfo depends on it. other prettification: common locking macro, whether lock timing is on or not.
This commit is contained in:
parent
c273654032
commit
88ba4b5268
7 changed files with 29 additions and 24 deletions
|
@ -67,7 +67,7 @@
|
||||||
#define ARG_MAX 4096 /* args + environ on small machines */
|
#define ARG_MAX 4096 /* args + environ on small machines */
|
||||||
#endif
|
#endif
|
||||||
#define CHILD_MAX _NO_LIMIT /* MINIX does not limit children */
|
#define CHILD_MAX _NO_LIMIT /* MINIX does not limit children */
|
||||||
#define OPEN_MAX 30 /* # open files a process may have */
|
#define OPEN_MAX 32 /* # open files a process may have */
|
||||||
#if 0 /* V1 file system */
|
#if 0 /* V1 file system */
|
||||||
#define LINK_MAX CHAR_MAX /* # links a file may have */
|
#define LINK_MAX CHAR_MAX /* # links a file may have */
|
||||||
#else /* V2 or better file system */
|
#else /* V2 or better file system */
|
||||||
|
|
|
@ -68,4 +68,7 @@ error "In <minix/sys_config.h> please define _MINIX_MACHINE to have a legal valu
|
||||||
error "_MINIX_MACHINE has incorrect value (0)"
|
error "_MINIX_MACHINE has incorrect value (0)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Kernel debug checks */
|
||||||
|
#define DEBUG_LOCK_CHECK 0 /* Interrupt Lock/unlock sanity checking. */
|
||||||
|
|
||||||
#endif /* _MINIX_SYS_CONFIG_H */
|
#endif /* _MINIX_SYS_CONFIG_H */
|
||||||
|
|
|
@ -104,7 +104,9 @@ struct kinfo {
|
||||||
int nr_tasks; /* number of kernel tasks */
|
int nr_tasks; /* number of kernel tasks */
|
||||||
char release[6]; /* kernel release number */
|
char release[6]; /* kernel release number */
|
||||||
char version[6]; /* kernel version number */
|
char version[6]; /* kernel version number */
|
||||||
int relocking; /* relocking check (for debugging) */
|
#if DEBUG_LOCK_CHECK
|
||||||
|
int relocking; /* interrupt locking depth (should be 0) */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Load data accounted every this no. of seconds. */
|
/* Load data accounted every this no. of seconds. */
|
||||||
|
|
|
@ -76,7 +76,6 @@
|
||||||
* For normal operation all options should be disabled.
|
* For normal operation all options should be disabled.
|
||||||
*/
|
*/
|
||||||
#define DEBUG_SCHED_CHECK 0 /* sanity check of scheduling queues */
|
#define DEBUG_SCHED_CHECK 0 /* sanity check of scheduling queues */
|
||||||
#define DEBUG_LOCK_CHECK 0 /* kernel lock() sanity check */
|
|
||||||
#define DEBUG_TIME_LOCKS 0 /* measure time spent in locks */
|
#define DEBUG_TIME_LOCKS 0 /* measure time spent in locks */
|
||||||
|
|
||||||
#endif /* CONFIG_H */
|
#endif /* CONFIG_H */
|
||||||
|
|
|
@ -58,11 +58,19 @@
|
||||||
#define IF_MASK 0x00000200
|
#define IF_MASK 0x00000200
|
||||||
#define IOPL_MASK 0x003000
|
#define IOPL_MASK 0x003000
|
||||||
|
|
||||||
|
#if DEBUG_LOCK_CHECK
|
||||||
|
#define reallock(c, v) { if (!(read_cpu_flags() & X86_FLAG_I)) { kinfo.relocking++; } else { intr_disable(); } }
|
||||||
|
#else
|
||||||
|
#define reallock(c, v) intr_disable()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define realunlock(c) intr_enable()
|
||||||
|
|
||||||
/* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
|
/* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
|
||||||
* are used when debugging is enabled. See debug.h for more information.
|
* are used when debugging is enabled. See debug.h for more information.
|
||||||
*/
|
*/
|
||||||
#define lock(c, v) intr_disable();
|
#define lock(c, v) reallock(c, v)
|
||||||
#define unlock(c) intr_enable();
|
#define unlock(c) realunlock(c)
|
||||||
|
|
||||||
/* Sizes of memory tables. The boot monitor distinguishes three memory areas,
|
/* Sizes of memory tables. The boot monitor distinguishes three memory areas,
|
||||||
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
||||||
|
|
|
@ -51,15 +51,6 @@ _PROTOTYPE( void timer_end, (int cat) );
|
||||||
#define locktimeend(c)
|
#define locktimeend(c)
|
||||||
#endif /* DEBUG_TIME_LOCKS */
|
#endif /* DEBUG_TIME_LOCKS */
|
||||||
|
|
||||||
/* The locking checks counts relocking situation, which are dangerous because
|
|
||||||
* the inner lock may unlock the outer one.
|
|
||||||
*/
|
|
||||||
#if DEBUG_LOCK_CHECK
|
|
||||||
#define lockcheck if (!(read_cpu_flags() & X86_FLAG_I)) kinfo.relocking++;
|
|
||||||
#else
|
|
||||||
#define lockcheck
|
|
||||||
#endif /* DEBUG_LOCK_CHECK */
|
|
||||||
|
|
||||||
/* This check makes sure that the scheduling queues are in a consistent state.
|
/* This check makes sure that the scheduling queues are in a consistent state.
|
||||||
* The check is run when the queues are updated with ready() and unready().
|
* The check is run when the queues are updated with ready() and unready().
|
||||||
*/
|
*/
|
||||||
|
@ -73,14 +64,9 @@ _PROTOTYPE( void check_runqueues, (char *when) );
|
||||||
*/
|
*/
|
||||||
#if (DEBUG_TIME_LOCKS || DEBUG_LOCK_CHECK)
|
#if (DEBUG_TIME_LOCKS || DEBUG_LOCK_CHECK)
|
||||||
# undef lock
|
# undef lock
|
||||||
# define lock(c, v) do { lockcheck; \
|
# define lock(c, v) do { reallock(c, v); locktimestart(c, v); } while(0)
|
||||||
intr_disable(); \
|
|
||||||
locktimestart(c, v); \
|
|
||||||
} while(0)
|
|
||||||
# undef unlock
|
# undef unlock
|
||||||
# define unlock(c) do { locktimeend(c); \
|
# define unlock(c) do { locktimeend(c); realunlock(c); } while(0)
|
||||||
intr_enable();\
|
|
||||||
} while(0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* DEBUG_H */
|
#endif /* DEBUG_H */
|
||||||
|
|
|
@ -669,8 +669,15 @@ PUBLIC void lock_dequeue(rp)
|
||||||
struct proc *rp; /* this process is no longer runnable */
|
struct proc *rp; /* this process is no longer runnable */
|
||||||
{
|
{
|
||||||
/* Safe gateway to dequeue() for tasks. */
|
/* Safe gateway to dequeue() for tasks. */
|
||||||
lock(4, "dequeue");
|
if (k_reenter >= 0) {
|
||||||
dequeue(rp);
|
/* We're in an exception or interrupt, so don't lock (and..
|
||||||
unlock(4);
|
* don't unlock).
|
||||||
|
*/
|
||||||
|
dequeue(rp);
|
||||||
|
} else {
|
||||||
|
lock(4, "dequeue");
|
||||||
|
dequeue(rp);
|
||||||
|
unlock(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue