From 39962dc92cbd2ee592ebe0921fa95b84065a37ab Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 9 May 2017 14:51:23 -0700 Subject: [PATCH] samples: use k_thread_create() Signed-off-by: Andrew Boie --- samples/bluetooth/hci_uart/src/main.c | 6 ++-- samples/bluetooth/ipsp/src/main.c | 7 +++-- samples/net/coaps_client/src/coaps_client.c | 6 ++-- samples/net/coaps_server/src/coaps_server.c | 6 ++-- samples/net/dhcpv4_client/src/main.c | 7 +++-- samples/net/dns_resolve/src/main.c | 7 +++-- samples/net/echo_client/src/echo-client.c | 28 +++++++++++-------- samples/net/echo_server/src/echo-server.c | 7 +++-- samples/net/http_server/src/https_server.c | 7 +++-- samples/net/irc_bot/src/irc-bot.c | 6 ++-- .../net/mbedtls_dtlsclient/src/dtls_client.c | 6 ++-- .../net/mbedtls_dtlsserver/src/dtls_server.c | 7 +++-- .../net/mbedtls_sslclient/src/mini_client.c | 6 ++-- samples/net/nats/src/main.c | 6 ++-- samples/net/telnet/src/telnet.c | 7 +++-- samples/net/wpan_serial/src/main.c | 12 +++++--- samples/net/wpanusb/src/wpanusb.c | 6 ++-- samples/net/zperf/src/zperf_tcp_receiver.c | 10 ++++--- samples/net/zperf/src/zperf_udp_receiver.c | 10 ++++--- samples/philosophers/src/main.c | 4 +-- samples/philosophers/src/phil_obj_abstract.h | 1 + samples/subsys/debug/sysview/src/main.c | 28 ++++++++++++------- samples/subsys/ipc/ipm_mailbox/ap/src/hello.c | 12 ++++---- samples/synchronization/src/main.c | 7 +++-- 24 files changed, 128 insertions(+), 81 deletions(-) diff --git a/samples/bluetooth/hci_uart/src/main.c b/samples/bluetooth/hci_uart/src/main.c index 9d4f05ee420..722402e92b6 100644 --- a/samples/bluetooth/hci_uart/src/main.c +++ b/samples/bluetooth/hci_uart/src/main.c @@ -30,6 +30,7 @@ static struct device *hci_uart_dev; static BT_STACK_NOINIT(tx_thread_stack, CONFIG_BLUETOOTH_HCI_TX_STACK_SIZE); +static struct k_thread tx_thread_data; /* HCI command buffers */ #define CMD_BUF_SIZE BT_BUF_RX_SIZE @@ -348,8 +349,9 @@ void main(void) /* Spawn the TX thread and start feeding commands and data to the * controller */ - k_thread_spawn(tx_thread_stack, sizeof(tx_thread_stack), tx_thread, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); + k_thread_create(&tx_thread_data, tx_thread_stack, + sizeof(tx_thread_stack), tx_thread, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); while (1) { struct net_buf *buf; diff --git a/samples/bluetooth/ipsp/src/main.c b/samples/bluetooth/ipsp/src/main.c index 75a3f2f54ef..e8f23672094 100644 --- a/samples/bluetooth/ipsp/src/main.c +++ b/samples/bluetooth/ipsp/src/main.c @@ -36,6 +36,7 @@ static struct in6_addr in6addr_my = MY_IP6ADDR; #define STACKSIZE 2000 char __noinit __stack thread_stack[STACKSIZE]; +static struct k_thread thread_data; #define MAX_DBG_PRINT 64 @@ -357,7 +358,7 @@ void main(void) printk("Advertising successfully started\n"); - k_thread_spawn(&thread_stack[0], STACKSIZE, - (k_thread_entry_t)listen, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, thread_stack, STACKSIZE, + (k_thread_entry_t)listen, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/coaps_client/src/coaps_client.c b/samples/net/coaps_client/src/coaps_client.c index bd1c06c0be4..83019b33cea 100644 --- a/samples/net/coaps_client/src/coaps_client.c +++ b/samples/net/coaps_client/src/coaps_client.c @@ -412,6 +412,7 @@ exit: #define STACK_SIZE 4096 u8_t stack[STACK_SIZE]; +static struct k_thread thread_data; static inline int init_app(void) { @@ -440,6 +441,7 @@ void main(void) return; } - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) dtls_client, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, stack, STACK_SIZE, + (k_thread_entry_t) dtls_client, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/coaps_server/src/coaps_server.c b/samples/net/coaps_server/src/coaps_server.c index 69044e0f9b0..2797c8a6c9f 100644 --- a/samples/net/coaps_server/src/coaps_server.c +++ b/samples/net/coaps_server/src/coaps_server.c @@ -633,6 +633,7 @@ exit: #define STACK_SIZE 4096 u8_t stack[STACK_SIZE]; +static struct k_thread thread_data; static inline int init_app(void) { @@ -660,7 +661,8 @@ void main(void) return; } - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) dtls_server, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, stack, STACK_SIZE, + (k_thread_entry_t) dtls_server, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/dhcpv4_client/src/main.c b/samples/net/dhcpv4_client/src/main.c index 3eacf28ec70..d3f629a6c79 100644 --- a/samples/net/dhcpv4_client/src/main.c +++ b/samples/net/dhcpv4_client/src/main.c @@ -25,6 +25,7 @@ #define STACKSIZE 2000 char __noinit __stack thread_stack[STACKSIZE]; +static struct k_thread thread_data; static struct net_mgmt_event_callback mgmt_cb; @@ -78,7 +79,7 @@ void main(void) { NET_INFO("In main"); - k_thread_spawn(&thread_stack[0], STACKSIZE, - (k_thread_entry_t)main_thread, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, &thread_stack[0], STACKSIZE, + (k_thread_entry_t)main_thread, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/dns_resolve/src/main.c b/samples/net/dns_resolve/src/main.c index 6c7bbce6ab5..2bcfc44c683 100644 --- a/samples/net/dns_resolve/src/main.c +++ b/samples/net/dns_resolve/src/main.c @@ -22,6 +22,7 @@ #define STACKSIZE 2000 char __noinit __stack thread_stack[STACKSIZE]; +static struct k_thread thread_data; #define DNS_TIMEOUT 2000 /* ms */ @@ -281,7 +282,7 @@ void main(void) { NET_INFO("Starting DNS resolve sample"); - k_thread_spawn(&thread_stack[0], STACKSIZE, - (k_thread_entry_t)network_setup, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, thread_stack, STACKSIZE, + (k_thread_entry_t)network_setup, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/echo_client/src/echo-client.c b/samples/net/echo_client/src/echo-client.c index a1e9b8f6724..33d14ff5aeb 100644 --- a/samples/net/echo_client/src/echo-client.c +++ b/samples/net/echo_client/src/echo-client.c @@ -160,10 +160,12 @@ static struct sockaddr_in6 peer_addr6 = { #if defined(CONFIG_NET_UDP) static char __noinit __stack ipv6_udp_stack[STACKSIZE]; +static struct k_thread ipv6_udp_thread_data; #endif #if defined(CONFIG_NET_TCP) static char __noinit __stack ipv6_tcp_stack[STACKSIZE]; +static struct k_thread ipv6_tcp_thread_data; #endif #endif /* CONFIG_NET_IPV6 */ @@ -189,10 +191,12 @@ static struct sockaddr_in peer_addr4 = { #if defined(CONFIG_NET_UDP) static char __noinit __stack ipv4_udp_stack[STACKSIZE]; +static struct k_thread ipv4_udp_thread_data; #endif #if defined(CONFIG_NET_TCP) static char __noinit __stack ipv4_tcp_stack[STACKSIZE]; +static struct k_thread ipv4_tcp_thread_data; #endif #endif /* CONFIG_NET_IPV4 */ @@ -870,27 +874,27 @@ static void event_iface_up(struct net_mgmt_event_callback *cb, } #if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_UDP) - k_thread_spawn(ipv4_udp_stack, STACKSIZE, - (k_thread_entry_t)send_udp_ipv4, - udp_send4, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&ipv4_udp_thread_data, ipv4_udp_stack, STACKSIZE, + (k_thread_entry_t)send_udp_ipv4, + udp_send4, NULL, NULL, K_PRIO_COOP(7), 0, 0); #endif #if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_TCP) - k_thread_spawn(ipv4_tcp_stack, STACKSIZE, - (k_thread_entry_t)send_tcp_ipv4, - tcp_send4, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&ipv4_tcp_thread_data, ipv4_tcp_stack, STACKSIZE, + (k_thread_entry_t)send_tcp_ipv4, + tcp_send4, NULL, NULL, K_PRIO_COOP(7), 0, 0); #endif #if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_UDP) - k_thread_spawn(ipv6_udp_stack, STACKSIZE, - (k_thread_entry_t)send_udp_ipv6, - udp_send6, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&ipv6_udp_thread_data, ipv6_udp_stack, STACKSIZE, + (k_thread_entry_t)send_udp_ipv6, + udp_send6, NULL, NULL, K_PRIO_COOP(7), 0, 0); #endif #if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_TCP) - k_thread_spawn(ipv6_tcp_stack, STACKSIZE, - (k_thread_entry_t)send_tcp_ipv6, - tcp_send6, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&ipv6_tcp_thread_data, ipv6_tcp_stack, STACKSIZE, + (k_thread_entry_t)send_tcp_ipv6, + tcp_send6, NULL, NULL, K_PRIO_COOP(7), 0, 0); #endif } diff --git a/samples/net/echo_server/src/echo-server.c b/samples/net/echo_server/src/echo-server.c index 493a0990910..1e0bf6f18a2 100644 --- a/samples/net/echo_server/src/echo-server.c +++ b/samples/net/echo_server/src/echo-server.c @@ -90,6 +90,7 @@ static struct net_buf_pool *data_udp_pool(void) #define STACKSIZE 2000 char __noinit __stack thread_stack[STACKSIZE]; +static struct k_thread thread_data; #define MAX_DBG_PRINT 64 @@ -582,7 +583,7 @@ void main(void) } #endif - k_thread_spawn(&thread_stack[0], STACKSIZE, - (k_thread_entry_t)receive, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, thread_stack, STACKSIZE, + (k_thread_entry_t)receive, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/http_server/src/https_server.c b/samples/net/http_server/src/https_server.c index d2834dbea30..53ba6c9b6d9 100644 --- a/samples/net/http_server/src/https_server.c +++ b/samples/net/http_server/src/https_server.c @@ -367,6 +367,7 @@ exit: #define STACK_SIZE 8192 u8_t stack[STACK_SIZE]; +struct k_thread https_thread; static inline int init_app(void) { @@ -400,7 +401,7 @@ void https_server_start(void) return; } - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) https_server, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); - + k_thread_create(&https_thread, stack, STACK_SIZE, + (k_thread_entry_t) https_server, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/irc_bot/src/irc-bot.c b/samples/net/irc_bot/src/irc-bot.c index aee00fa0c0b..8f21aa9b86a 100644 --- a/samples/net/irc_bot/src/irc-bot.c +++ b/samples/net/irc_bot/src/irc-bot.c @@ -30,6 +30,7 @@ #define STACK_SIZE 2048 u8_t stack[STACK_SIZE]; +static struct k_thread bot_thread; #define CMD_BUFFER_SIZE 256 static u8_t cmd_buf[CMD_BUFFER_SIZE]; @@ -1068,6 +1069,7 @@ static void irc_bot(void) void main(void) { - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t)irc_bot, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&bot_thread, stack, STACK_SIZE, + (k_thread_entry_t)irc_bot, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/mbedtls_dtlsclient/src/dtls_client.c b/samples/net/mbedtls_dtlsclient/src/dtls_client.c index 60175e22f3a..aa81712680d 100644 --- a/samples/net/mbedtls_dtlsclient/src/dtls_client.c +++ b/samples/net/mbedtls_dtlsclient/src/dtls_client.c @@ -285,6 +285,7 @@ exit: #define STACK_SIZE 8192 u8_t stack[STACK_SIZE]; +static struct k_thread dtls_thread; static inline int init_app(void) { @@ -328,7 +329,8 @@ void main(void) return; } - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) dtls_client, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&dtls_thread, stack, STACK_SIZE, + (k_thread_entry_t) dtls_client, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/mbedtls_dtlsserver/src/dtls_server.c b/samples/net/mbedtls_dtlsserver/src/dtls_server.c index 97822a8a892..4e865430407 100644 --- a/samples/net/mbedtls_dtlsserver/src/dtls_server.c +++ b/samples/net/mbedtls_dtlsserver/src/dtls_server.c @@ -363,6 +363,7 @@ exit: #define STACK_SIZE 8192 u8_t stack[STACK_SIZE]; +static struct k_thread dtls_thread; static inline int init_app(void) { @@ -405,7 +406,7 @@ void main(void) return; } - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) dtls_server, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); - + k_thread_create(&dtls_thread, stack, STACK_SIZE, + (k_thread_entry_t) dtls_server, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/mbedtls_sslclient/src/mini_client.c b/samples/net/mbedtls_sslclient/src/mini_client.c index 806694dd97d..5c64aab773f 100644 --- a/samples/net/mbedtls_sslclient/src/mini_client.c +++ b/samples/net/mbedtls_sslclient/src/mini_client.c @@ -316,9 +316,11 @@ exit: #define STACK_SIZE 8192 u8_t stack[STACK_SIZE]; +static struct k_thread tls_thread; void main(void) { - k_thread_spawn(stack, STACK_SIZE, (k_thread_entry_t) tls_client, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&tls_thread, stack, STACK_SIZE, + (k_thread_entry_t) tls_client, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/nats/src/main.c b/samples/net/nats/src/main.c index f917b61e663..394c074d2f3 100644 --- a/samples/net/nats/src/main.c +++ b/samples/net/nats/src/main.c @@ -71,6 +71,7 @@ static bool fake_led; #define DEFAULT_PORT 4222 static u8_t stack[2048]; +static struct k_thread thread_data; static void panic(const char *msg) { @@ -320,6 +321,7 @@ static void nats_client(void) void main(void) { - k_thread_spawn(stack, sizeof(stack), (k_thread_entry_t)nats_client, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, stack, sizeof(stack), + (k_thread_entry_t)nats_client, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/telnet/src/telnet.c b/samples/net/telnet/src/telnet.c index 4a0b45eb0bb..84cd15a9a03 100644 --- a/samples/net/telnet/src/telnet.c +++ b/samples/net/telnet/src/telnet.c @@ -21,6 +21,7 @@ #define STACKSIZE 2000 char __noinit __stack thread_stack[STACKSIZE]; +static struct k_thread thread_data; #if defined(CONFIG_NET_DHCPV4) static struct net_mgmt_event_callback mgmt_cb; @@ -144,7 +145,7 @@ void main(void) { NET_INFO("Starting Telnet sample"); - k_thread_spawn(&thread_stack[0], STACKSIZE, - (k_thread_entry_t)network_setup, - NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); + k_thread_create(&thread_data, thread_stack, STACKSIZE, + (k_thread_entry_t)network_setup, + NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0); } diff --git a/samples/net/wpan_serial/src/main.c b/samples/net/wpan_serial/src/main.c index fff21728fbd..f0222b691ff 100644 --- a/samples/net/wpan_serial/src/main.c +++ b/samples/net/wpan_serial/src/main.c @@ -43,11 +43,13 @@ enum slip_state { /* RX queue */ static struct k_fifo rx_queue; static char __noinit __stack rx_stack[1024]; +static struct k_thread rx_thread_data; /* TX queue */ static struct k_sem tx_sem; static struct k_fifo tx_queue; static char __noinit __stack tx_stack[1024]; +static struct k_thread tx_thread_data; /* Buffer for SLIP encoded data for the worst case */ static u8_t slip_buf[1 + 2 * CONFIG_NET_BUF_DATA_SIZE]; @@ -470,8 +472,9 @@ static void init_rx_queue(void) { k_fifo_init(&rx_queue); - k_thread_spawn(rx_stack, sizeof(rx_stack), (k_thread_entry_t)rx_thread, - NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); + k_thread_create(&rx_thread_data, rx_stack, sizeof(rx_stack), + (k_thread_entry_t)rx_thread, + NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); } static void init_tx_queue(void) @@ -479,8 +482,9 @@ static void init_tx_queue(void) k_sem_init(&tx_sem, 0, UINT_MAX); k_fifo_init(&tx_queue); - k_thread_spawn(tx_stack, sizeof(tx_stack), (k_thread_entry_t)tx_thread, - NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); + k_thread_create(&tx_thread_data, tx_stack, sizeof(tx_stack), + (k_thread_entry_t)tx_thread, + NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); } /** diff --git a/samples/net/wpanusb/src/wpanusb.c b/samples/net/wpanusb/src/wpanusb.c index 9ee8c50b58e..1707484b088 100644 --- a/samples/net/wpanusb/src/wpanusb.c +++ b/samples/net/wpanusb/src/wpanusb.c @@ -76,6 +76,7 @@ static struct k_fifo tx_queue; * Stack for the tx thread. */ static char __noinit __stack tx_stack[1024]; +static struct k_thread tx_thread_data; #define DEV_DATA(dev) \ ((struct wpanusb_dev_data_t * const)(dev)->driver_data) @@ -530,8 +531,9 @@ static void init_tx_queue(void) /* Transmit queue init */ k_fifo_init(&tx_queue); - k_thread_spawn(tx_stack, sizeof(tx_stack), (k_thread_entry_t)tx_thread, - NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); + k_thread_create(&tx_thread_data, tx_stack, sizeof(tx_stack), + (k_thread_entry_t)tx_thread, + NULL, NULL, NULL, K_PRIO_COOP(8), 0, K_NO_WAIT); } extern enum net_verdict ieee802154_radio_handle_ack(struct net_if *iface, diff --git a/samples/net/zperf/src/zperf_tcp_receiver.c b/samples/net/zperf/src/zperf_tcp_receiver.c index 0efca5d246f..b0deb0f3390 100644 --- a/samples/net/zperf/src/zperf_tcp_receiver.c +++ b/samples/net/zperf/src/zperf_tcp_receiver.c @@ -29,6 +29,7 @@ #define TCP_RX_FIBER_STACK_SIZE 1024 static char __noinit __stack zperf_tcp_rx_stack[TCP_RX_FIBER_STACK_SIZE]; +static struct k_thread zperf_tcp_rx_thread_data; #if defined(CONFIG_NET_IPV6) static struct sockaddr_in6 *in6_addr_my; @@ -240,8 +241,9 @@ void zperf_tcp_receiver_init(int port) in4_addr_my = zperf_get_sin(); #endif - k_thread_spawn(zperf_tcp_rx_stack, sizeof(zperf_tcp_rx_stack), - (k_thread_entry_t)zperf_tcp_rx_thread, - INT_TO_POINTER(port), 0, 0, - K_PRIO_COOP(7), 0, K_NO_WAIT); + k_thread_create(&zperf_tcp_rx_thread_data, zperf_tcp_rx_stack, + sizeof(zperf_tcp_rx_stack), + (k_thread_entry_t)zperf_tcp_rx_thread, + INT_TO_POINTER(port), 0, 0, + K_PRIO_COOP(7), 0, K_NO_WAIT); } diff --git a/samples/net/zperf/src/zperf_udp_receiver.c b/samples/net/zperf/src/zperf_udp_receiver.c index c4706344697..62b38504a7d 100644 --- a/samples/net/zperf/src/zperf_udp_receiver.c +++ b/samples/net/zperf/src/zperf_udp_receiver.c @@ -29,6 +29,7 @@ /* Static data */ static char __noinit __stack zperf_rx_stack[RX_THREAD_STACK_SIZE]; +static struct k_thread zperf_rx_thread_data; static struct sockaddr_in6 *in6_addr_my; static struct sockaddr_in *in4_addr_my; @@ -383,8 +384,9 @@ void zperf_receiver_init(int port) in4_addr_my = zperf_get_sin(); #endif - k_thread_spawn(zperf_rx_stack, sizeof(zperf_rx_stack), - (k_thread_entry_t)zperf_rx_thread, - INT_TO_POINTER(port), 0, 0, - K_PRIO_COOP(7), 0, K_NO_WAIT); + k_thread_create(&zperf_rx_thread_data, zperf_rx_stack, + sizeof(zperf_rx_stack), + (k_thread_entry_t)zperf_rx_thread, + INT_TO_POINTER(port), 0, 0, + K_PRIO_COOP(7), 0, K_NO_WAIT); } diff --git a/samples/philosophers/src/main.c b/samples/philosophers/src/main.c index d218031bebc..417f96f7769 100644 --- a/samples/philosophers/src/main.c +++ b/samples/philosophers/src/main.c @@ -230,8 +230,8 @@ static void start_threads(void) for (int i = 0; i < NUM_PHIL; i++) { int prio = new_prio(i); - k_thread_spawn(&stacks[i][0], STACK_SIZE, - philosopher, (void *)i, NULL, NULL, prio, 0, 0); + k_thread_create(&threads[i], &stacks[i][0], STACK_SIZE, + philosopher, (void *)i, NULL, NULL, prio, 0, 0); } } diff --git a/samples/philosophers/src/phil_obj_abstract.h b/samples/philosophers/src/phil_obj_abstract.h index 2ae78922aad..86556576c52 100644 --- a/samples/philosophers/src/phil_obj_abstract.h +++ b/samples/philosophers/src/phil_obj_abstract.h @@ -157,5 +157,6 @@ static fork_t forks[NUM_PHIL] = { }; static char __stack __noinit stacks[NUM_PHIL][STACK_SIZE]; +static struct k_thread threads[NUM_PHIL]; #endif /* phil_obj_abstract__h */ diff --git a/samples/subsys/debug/sysview/src/main.c b/samples/subsys/debug/sysview/src/main.c index 57a4263baa4..5625790bcc1 100644 --- a/samples/subsys/debug/sysview/src/main.c +++ b/samples/subsys/debug/sysview/src/main.c @@ -15,8 +15,12 @@ static u8_t printer_stack[1024]; static u8_t calc_stack[1024]; - static u8_t sysview_stack[2048]; + +static struct k_thread printer_thread_data; +static struct k_thread calc_thread_data; +static struct k_thread sysview_thread_data; + static u32_t timestamp, interrupt; extern SEGGER_RTT_CB _SEGGER_RTT; @@ -245,14 +249,18 @@ static void calc_thread(void) void main(void) { - k_thread_spawn(sysview_stack, sizeof(sysview_stack), - (k_thread_entry_t)sysview_thread, - NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); + k_thread_create(&sysview_thread_data, sysview_stack, + sizeof(sysview_stack), + (k_thread_entry_t)sysview_thread, + NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); - k_thread_spawn(printer_stack, sizeof(printer_stack), - (k_thread_entry_t)printer_thread, - NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); - k_thread_spawn(calc_stack, sizeof(calc_stack), - (k_thread_entry_t)calc_thread, - NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); + k_thread_create(&printer_thread_data, printer_stack, + sizeof(printer_stack), + (k_thread_entry_t)printer_thread, + NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); + + k_thread_create(&calc_thread_data, calc_stack, + sizeof(calc_stack), + (k_thread_entry_t)calc_thread, + NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); } diff --git a/samples/subsys/ipc/ipm_mailbox/ap/src/hello.c b/samples/subsys/ipc/ipm_mailbox/ap/src/hello.c index 1d46e3157d0..4030f82daa2 100644 --- a/samples/subsys/ipc/ipm_mailbox/ap/src/hello.c +++ b/samples/subsys/ipc/ipm_mailbox/ap/src/hello.c @@ -28,6 +28,7 @@ QUARK_SE_IPM_DEFINE(message_ipm2, 3, QUARK_SE_IPM_OUTBOUND); #define TASK_PRIO 7 char thread_stacks[2][STACKSIZE]; +static struct k_thread threads[2]; u32_t scss_reg(u32_t offset) { @@ -133,11 +134,12 @@ void main(void) { printk("===== app started ========\n"); - k_thread_spawn(&thread_stacks[0][0], STACKSIZE, main_thread, - 0, 0, 0, K_PRIO_COOP(MAIN_FIBER_PRI), 0, 0); - - k_thread_spawn(&thread_stacks[1][0], STACKSIZE, ping_source_thread, - 0, 0, 0, K_PRIO_COOP(PING_FIBER_PRI), 0, 0); + k_thread_create(&threads[0], &thread_stacks[0][0], STACKSIZE, + main_thread, 0, 0, 0, + K_PRIO_COOP(MAIN_FIBER_PRI), 0, 0); + k_thread_create(&threads[0], &thread_stacks[1][0], STACKSIZE, + ping_source_thread, 0, 0, 0, + K_PRIO_COOP(PING_FIBER_PRI), 0, 0); } diff --git a/samples/synchronization/src/main.c b/samples/synchronization/src/main.c index 8eceb28e2b2..55eebe999dd 100644 --- a/samples/synchronization/src/main.c +++ b/samples/synchronization/src/main.c @@ -67,7 +67,7 @@ void threadB(void *dummy1, void *dummy2, void *dummy3) } char __noinit __stack threadB_stack_area[STACKSIZE]; - +static struct k_thread threadB_data; /* threadA is a static thread that is spawned automatically */ @@ -78,8 +78,9 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) ARG_UNUSED(dummy3); /* spawn threadB */ - k_thread_spawn(threadB_stack_area, STACKSIZE, threadB, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + k_thread_create(&threadB_data, threadB_stack_area, STACKSIZE, + threadB, NULL, NULL, NULL, + PRIORITY, 0, K_NO_WAIT); /* invoke routine to ping-pong hello messages with threadB */ helloLoop(__func__, &threadA_sem, &threadB_sem);