Skip to content

Commit e297de8

Browse files
locking fix for dc11::operator()()
1 parent 2153fed commit e297de8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dc11.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ void dc11::operator()()
105105
DOLOG(info, true, "DC11 thread started");
106106

107107
while(!stop_flag) {
108-
myusleep(5000); // TODO replace polling
108+
myusleep(10000); // TODO replace polling
109109

110110
for(size_t line_nr=0; line_nr<comm_interfaces.size(); line_nr++) {
111+
std::unique_lock<std::mutex> lck(input_lock[line_nr]);
112+
111113
// (dis-)connected?
112114
bool is_connected = comm_interfaces.at(line_nr)->is_connected();
113115

@@ -128,7 +130,6 @@ void dc11::operator()()
128130
while(comm_interfaces.at(line_nr)->has_data()) {
129131
uint8_t buffer = comm_interfaces.at(line_nr)->get_byte();
130132

131-
std::unique_lock<std::mutex> lck(input_lock[line_nr]);
132133
recv_buffers[line_nr].push_back(char(buffer));
133134

134135
have_data = true;
@@ -234,6 +235,7 @@ uint16_t dc11::read_word(const uint16_t addr)
234235
return vtemp;
235236
}
236237

238+
// FIXME locking
237239
void dc11::write_byte(const uint16_t addr, const uint8_t v)
238240
{
239241
uint16_t vtemp = registers[(addr - DC11_BASE) / 2];

0 commit comments

Comments
 (0)