samples: net: Adjust the thread priorities

If networking pre-emptive thread priorities are enabled,
then use the proper macro to enable them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-10-07 13:50:00 +03:00 committed by Jukka Rissanen
commit 6e54f5462c
9 changed files with 51 additions and 8 deletions

View file

@ -498,7 +498,12 @@ static void start_app(void)
#if defined(CONFIG_USERSPACE)
#define STACK_SIZE 2048
#define THREAD_PRIORITY K_PRIO_COOP(8)
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
K_THREAD_DEFINE(app_thread, STACK_SIZE,
start_app, NULL, NULL, NULL,

View file

@ -36,7 +36,11 @@ static const unsigned char private_key[] = {
#else
#define STACK_SIZE 1024
#endif
#define THREAD_PRIORITY K_PRIO_COOP(0)
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
static const char content[] = {
#if defined(CONFIG_NET_SAMPLE_SERVE_LARGE_FILE)

View file

@ -21,6 +21,12 @@ extern struct k_mem_domain app_domain;
#define APP_DMEM
#endif
#if IS_ENABLED(CONFIG_NET_TC_THREAD_PREEMPTIVE)
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#else
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#endif
struct data {
const char *proto;

View file

@ -314,6 +314,8 @@ void main(void)
k_sem_give(&run_app);
}
k_thread_priority_set(k_current_get(), THREAD_PRIORITY);
#if defined(CONFIG_USERSPACE)
k_thread_access_grant(k_current_get(), &run_app);
k_mem_domain_add_thread(&app_domain, k_current_get());

View file

@ -13,7 +13,13 @@
#else
#define STACK_SIZE 1024
#endif
#define THREAD_PRIORITY K_PRIO_COOP(8)
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
#define RECV_BUFFER_SIZE 1280
#if defined(CONFIG_USERSPACE)

View file

@ -16,7 +16,11 @@ LOG_MODULE_REGISTER(net_mgmt_sock_sample, LOG_LEVEL_DBG);
#define MAX_BUF_LEN 64
#define STACK_SIZE 1024
#define THREAD_PRIORITY K_PRIO_COOP(8)
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
/* A test thread that spits out events that we can catch and show to user */
static void trigger_events(void)

View file

@ -15,7 +15,11 @@ LOG_MODULE_REGISTER(net_pkt_sock_sample, LOG_LEVEL_DBG);
#include <net/ethernet.h>
#define STACK_SIZE 1024
#define THREAD_PRIORITY K_PRIO_COOP(8)
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
#define RECV_BUFFER_SIZE 1280
#define WAIT_TIME CONFIG_NET_SAMPLE_SEND_WAIT_TIME

View file

@ -24,6 +24,12 @@ LOG_MODULE_REGISTER(wpan_serial, CONFIG_USB_DEVICE_LOG_LEVEL);
#include <net_private.h>
#include <net/ieee802154_radio.h>
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
#define SLIP_END 0300
#define SLIP_ESC 0333
#define SLIP_ESC_END 0334
@ -414,7 +420,7 @@ static void init_rx_queue(void)
k_thread_create(&rx_thread_data, rx_stack,
K_THREAD_STACK_SIZEOF(rx_stack),
(k_thread_entry_t)rx_thread,
NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT);
NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT);
}
static void init_tx_queue(void)
@ -424,7 +430,7 @@ static void init_tx_queue(void)
k_thread_create(&tx_thread_data, tx_stack,
K_THREAD_STACK_SIZEOF(tx_stack),
(k_thread_entry_t)tx_thread,
NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT);
NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT);
}
/**

View file

@ -19,6 +19,12 @@ LOG_MODULE_REGISTER(wpanusb);
#include "wpanusb.h"
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
#define WPANUSB_SUBCLASS 0
#define WPANUSB_PROTOCOL 0
@ -340,7 +346,7 @@ static void init_tx_queue(void)
k_thread_create(&tx_thread_data, tx_stack,
K_THREAD_STACK_SIZEOF(tx_stack),
(k_thread_entry_t)tx_thread,
NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT);
NULL, NULL, NULL, THREAD_PRIORITY, 0, K_NO_WAIT);
}
/**