Use atomic ops to close a race condition on the in_Debugger variable used

to only allow 1 CPU at a time to (non-recursively) enter the debugger.
This commit is contained in:
John Baldwin 2000-11-28 23:15:44 +00:00
parent 9a51cfcde1
commit bf8bfade99
2 changed files with 6 additions and 8 deletions

View File

@ -306,7 +306,7 @@ void
Debugger(msg)
const char *msg;
{
static volatile u_char in_Debugger;
static volatile u_int in_Debugger;
int flags;
/*
* XXX
@ -317,14 +317,13 @@ Debugger(msg)
if (cons_unavail && !(boothowto & RB_GDB))
return;
if (!in_Debugger) {
if (atomic_cmpset_int(&in_Debugger, 0, 1)) {
flags = save_intr();
disable_intr();
in_Debugger = 1;
db_printf("Debugger(\"%s\")\n", msg);
breakpoint();
in_Debugger = 0;
restore_intr(flags);
in_Debugger = 0;
}
}

View File

@ -306,7 +306,7 @@ void
Debugger(msg)
const char *msg;
{
static volatile u_char in_Debugger;
static volatile u_int in_Debugger;
int flags;
/*
* XXX
@ -317,14 +317,13 @@ Debugger(msg)
if (cons_unavail && !(boothowto & RB_GDB))
return;
if (!in_Debugger) {
if (atomic_cmpset_int(&in_Debugger, 0, 1)) {
flags = save_intr();
disable_intr();
in_Debugger = 1;
db_printf("Debugger(\"%s\")\n", msg);
breakpoint();
in_Debugger = 0;
restore_intr(flags);
in_Debugger = 0;
}
}