picotcp: enable multithreading. protect bba input queue with mutex.
tentative fix for MINIDUMP-1Y
This commit is contained in:
parent
4376e89149
commit
fceb170a2a
|
@ -24,6 +24,8 @@
|
||||||
#define TIME_PRESCALE
|
#define TIME_PRESCALE
|
||||||
#define PICO_SUPPORT_THREADING
|
#define PICO_SUPPORT_THREADING
|
||||||
*/
|
*/
|
||||||
|
#define PICO_SUPPORT_THREADING
|
||||||
|
|
||||||
#if defined(NDEBUG) && !defined(DEBUGFAST)
|
#if defined(NDEBUG) && !defined(DEBUGFAST)
|
||||||
#define dbg(...)
|
#define dbg(...)
|
||||||
#else
|
#else
|
||||||
|
@ -127,6 +129,7 @@ static inline uint32_t PICO_TIME_MS(void)
|
||||||
extern void *pico_mutex_init(void);
|
extern void *pico_mutex_init(void);
|
||||||
extern void pico_mutex_lock(void *mux);
|
extern void pico_mutex_lock(void *mux);
|
||||||
extern void pico_mutex_unlock(void *mux);
|
extern void pico_mutex_unlock(void *mux);
|
||||||
|
extern void pico_mutex_deinit(void *mux);
|
||||||
|
|
||||||
/* semaphore implementations (only used in wrapper code) */
|
/* semaphore implementations (only used in wrapper code) */
|
||||||
extern void *pico_sem_init(void);
|
extern void *pico_sem_init(void);
|
||||||
|
|
|
@ -938,6 +938,7 @@ static void *pico_thread_func(void *)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
pico_dev->send = &send_eth_frame;
|
pico_dev->send = &send_eth_frame;
|
||||||
pico_dev->proxied = 1;
|
pico_dev->proxied = 1;
|
||||||
|
pico_queue_protect(pico_dev->q_in);
|
||||||
|
|
||||||
pico_string_to_ipv4("192.168.169.1", &addr);
|
pico_string_to_ipv4("192.168.169.1", &addr);
|
||||||
pico_ip4 ipaddr;
|
pico_ip4 ipaddr;
|
||||||
|
@ -1091,3 +1092,24 @@ void stop_pico()
|
||||||
pico_thread_running = false;
|
pico_thread_running = false;
|
||||||
pico_thread.WaitToEnd();
|
pico_thread.WaitToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// picotcp mutex implementation
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
void *pico_mutex_init(void) {
|
||||||
|
return new std::mutex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pico_mutex_lock(void *mux) {
|
||||||
|
((std::mutex *)mux)->lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pico_mutex_unlock(void *mux) {
|
||||||
|
((std::mutex *)mux)->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pico_mutex_deinit(void *mux) {
|
||||||
|
delete (std::mutex *)mux;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue