Make CPU code thread safe
This commit is contained in:
@@ -183,6 +183,9 @@ void gdbstub_thread_gdb()
|
||||
// g : read all registers -> send back all registers
|
||||
char resp[32 * 8 + 8 + 1] = {0};
|
||||
|
||||
// Obtain CPU0 mutex
|
||||
pthread_mutex_lock(cpu0_mutex);
|
||||
|
||||
// All general purpose registers in host byte order as chars
|
||||
for(size_t i = 0; i < 32; i++)
|
||||
{
|
||||
@@ -194,6 +197,9 @@ void gdbstub_thread_gdb()
|
||||
uint32_t pc = htonl(cpu0->pc);
|
||||
snprintf(resp + 32 * 8, 9, "%08x", pc);
|
||||
|
||||
// Let go of CPU0 mutex
|
||||
pthread_mutex_unlock(cpu0_mutex);
|
||||
|
||||
// Final packet size, send packet
|
||||
size_t size = 32 * 8 + 8;
|
||||
gdbstub_send_packet(resp, size);
|
||||
@@ -202,6 +208,9 @@ void gdbstub_thread_gdb()
|
||||
{
|
||||
// G : write all registers -> read and set all registers
|
||||
|
||||
// Obtain CPU0 mutex
|
||||
pthread_mutex_lock(cpu0_mutex);
|
||||
|
||||
// All general purpose registers in host byte order as chars
|
||||
for(size_t i = 1; i < 32; i++)
|
||||
{
|
||||
@@ -218,6 +227,9 @@ void gdbstub_thread_gdb()
|
||||
pc = ntohl(pc);
|
||||
cpu0->pc = pc;
|
||||
|
||||
// Let go of CPU0 Mutex
|
||||
pthread_mutex_unlock(cpu0_mutex);
|
||||
|
||||
gdbstub_send_packet("OK", 2);
|
||||
}
|
||||
else if(packet[0] == 'm')
|
||||
|
Reference in New Issue
Block a user