Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

删除rt_thread_sleep遗留 #9302

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bsp/efm32/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,15 @@ void rt_demo_thread_entry(void* parameter)
struct efm32_accel_result_t result;

rt_kprintf(">>> waiting\n");
rt_thread_sleep(6000);
rt_thread_delay(6000);
rt_kprintf(">>> start\n");
while(1)
{
efm_accel_get_data(&result);
rt_kprintf("Accel x: %x\n", result.x);
rt_kprintf("Accel y: %x\n", result.y);
rt_kprintf("Accel z: %x\n\n", result.z);
rt_thread_sleep(200);
rt_thread_delay(200);
}
}
#endif
Expand Down Expand Up @@ -644,7 +644,7 @@ void rt_demo_thread_entry(void* parameter)
}

/* start display photos */
rt_thread_sleep(100);
rt_thread_delay(100);
do
{
/* get a photo */
Expand Down Expand Up @@ -680,7 +680,7 @@ void rt_demo_thread_entry(void* parameter)
}

rtgui_send(photo_app, &event.win.parent, sizeof(event));
rt_thread_sleep(2000);
rt_thread_delay(2000);
} while (dirent != RT_NULL);
closedir(dir);

Expand All @@ -694,7 +694,7 @@ void rt_demo_thread_entry(void* parameter)
emu_em2_enable();
while(1)
{
rt_thread_sleep(10);
rt_thread_delay(10);
}
}

Expand Down
4 changes: 2 additions & 2 deletions bsp/efm32/dev_accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ rt_err_t efm_accel_auto_zero(rt_uint8_t mode, rt_tick_t period)
accel_debug("Accel: Offset %+d %+d %+d\n", *(rt_int16_t *)&cmd[1], \
*(rt_int16_t *)&cmd[3], *(rt_int16_t *)&cmd[5]);
#endif
rt_thread_sleep(1);
rt_thread_delay(1);
}
}
else
Expand Down Expand Up @@ -695,7 +695,7 @@ rt_err_t efm_accel_auto_zero(rt_uint8_t mode, rt_tick_t period)
{
max.z = sum.z;
}
rt_thread_sleep(1);
rt_thread_delay(1);
} while (accelInTime);

accel_debug("Accel: Min %+d %+d %+d, max %+d %+d %+d\n",
Expand Down
2 changes: 1 addition & 1 deletion bsp/efm32/drv_leuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static rt_ssize_t rt_leuart_write (
// {
// while(leuart->state & LEUART_STATE_TX_BUSY)
// {
// rt_thread_sleep(LEUART_WAIT_TIME_TX);
// rt_thread_delay(LEUART_WAIT_TIME_TX);
// }
// }
// TODO: This function blocks the process
Expand Down
4 changes: 2 additions & 2 deletions bsp/efm32/drv_usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ static rt_ssize_t rt_usart_write (
// {
// while(usart->state & USART_STATE_TX_BUSY)
// {
// rt_thread_sleep(USART_WAIT_TIME_TX);
// rt_thread_delay(USART_WAIT_TIME_TX);
// }
// }
}
Expand Down Expand Up @@ -699,7 +699,7 @@ static rt_ssize_t rt_usart_write (
// {
// while(usart->state & USART_STATE_TX_BUSY)
// {
// rt_thread_sleep(USART_WAIT_TIME_TX);
// rt_thread_delay(USART_WAIT_TIME_TX);
// }
// }
write_size = size;
Expand Down
6 changes: 3 additions & 3 deletions bsp/sep6200/application/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
void rt_init_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(200);
rt_thread_delay(200);
rt_hw_console_output("init thread\n");
}
}

void rt_test1_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(800);
rt_thread_delay(800);
rt_hw_console_output("test1 thread\n");
}
}

void rt_test2_thread_entry(void *parameter)
{
while(1){
rt_thread_sleep(300);
rt_thread_delay(300);
rt_hw_console_output("test2 thread\n");
}
}
Expand Down
5 changes: 2 additions & 3 deletions documentation/thread/thread.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看文档中这个线程控制块结构体也好久没更新了

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
rt_uint8_t flags; /* Flag Position */

rt_list_t list; /* Object List */
rt_list_t tlist; /* Thread List */

Check failure on line 46 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`tlist` is not a recognized word. (unrecognized-spelling)

/* Stack Pointer and Entry pointer */
void *sp; /* Stack Pointer */
Expand All @@ -63,7 +63,7 @@

......

rt_ubase_t init_tick; /* Thread Initialization Count Value */

Check failure on line 66 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`ubase` is not a recognized word. (unrecognized-spelling)
rt_ubase_t remaining_tick; /* Thread Remaining Count Value */

struct rt_timer thread_timer; /* Built-in Thread Timer */
Expand Down Expand Up @@ -115,7 +115,7 @@

Each thread has a time slice parameter, but time slice is only valid for ready-state threads of the same priority. The system schedules the ready-state threads with the same priority using time slice rotation scheduling method. In this case, time slice plays the role of constraining thread's single running time and the unit is a system tick (OS Tick). Suppose there are 2 ready-state threads, A and B with the same priority. Time slice of A thread is set to 10, and time slice of B thread is set to 5. When there is no ready-state thread with higher priority than A in the system, the system will switch back and forth between thread A and B. Each time the system performs 10 OS Ticks on thread A, and 5 OS Ticks on thread B, as shown below.

![Same Priority Time Slice Round Robin](figures/04time_slience.png)

Check failure on line 118 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`slience` is not a recognized word. (unrecognized-spelling)

#### Thread Entry Function

Expand Down Expand Up @@ -159,11 +159,11 @@
Each thread is one execution scenario. Error codes are closely related to the execution environment, so each thread is equipped with a variable to store the error code. These error codes are as follows:

```c
#define RT_EOK 0 /* No error */

Check failure on line 162 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`EOK` is not a recognized word. (unrecognized-spelling)
#define RT_ERROR 1 /* Regular error */
#define RT_ETIMEOUT 2 /* Timeout error */
#define RT_EFULL 3 /* Resource is full */

Check failure on line 165 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`EFULL` is not a recognized word. (unrecognized-spelling)
#define RT_EEMPTY 4 /* No resource */

Check failure on line 166 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`EEMPTY` is not a recognized word. (unrecognized-spelling)
#define RT_ENOMEM 5 /* No memory */
#define RT_ENOSYS 6 /* System does not support */
#define RT_EBUSY 7 /* System busy */
Expand Down Expand Up @@ -224,7 +224,7 @@
rt_uint32_t tick);
```

When this function is called, the system will allocate a thread handle from the dynamic heap memory and allocate the corresponding space from the dynamic heap memory according to the stack size specified in the parameter. The allocated stack space is aligned in RT_ALIGN_SIZE mode configured in rtconfig.h. The parameters and return values of the thread creation `rt_thread_create()` are as follows:

Check failure on line 227 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`rtconfig` is not a recognized word. (unrecognized-spelling)

|Parameters |Description |
|------------|----------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -353,16 +353,15 @@
In practical applications, we sometimes need to delay the current thread running for a period of time and re-run at a specified time. This is called "thread sleep". Thread sleep can use the following three function interfaces:

```c
rt_err_t rt_thread_sleep(rt_tick_t tick);
rt_err_t rt_thread_delay(rt_tick_t tick);
rt_err_t rt_thread_mdelay(rt_int32_t ms);

Check failure on line 357 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`mdelay` is not a recognized word. (unrecognized-spelling)
```

These three function interfaces have the same effect. Calling them can cause the current thread to suspend for a specified period of time. After, the thread will wake up and enter the ready state again. This function accepts a parameter that specifies the sleep time of the thread. The parameters and return values of the thread sleep interface rt_thread_sleep/delay/mdelay() are as follows:
These three function interfaces have the same effect. Calling them can cause the current thread to suspend for a specified period of time. After, the thread will wake up and enter the ready state again. This function accepts a parameter that specifies the sleep time of the thread. The parameters and return values of the thread sleep interface rt_thread_delay/mdelay() are as follows:

|**Parameters**|Description |
| -------- | ------------------------------------------------------------ |
| tick/ms | Thread sleep time:<br>The input parameter tick of rt_thread_sleep/rt_thread_delay is in units of 1 OS Tick; <br>The input parameter ms of rt_thread_mdelay is in units of 1ms; |
| tick/ms | Thread sleep time:<br>The input parameter tick of rt_thread_delay is in units of 1 OS Tick; <br>The input parameter ms of rt_thread_mdelay is in units of 1ms; |
|**Return**| —— |
| RT_EOK | Successful operation. |

Expand Down Expand Up @@ -436,8 +435,8 @@
The idle hook function is a hook function of the idle thread. If the idle hook function is set, the idle hook function can be automatically executed to perform other things, such as the LED of system indicator , when the system executes the idle thread. The interface for setting/deleting idle hooks is as follows:

```c
rt_err_t rt_thread_idle_sethook(void (*hook)(void));

Check failure on line 438 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`sethook` is not a recognized word. (unrecognized-spelling)
rt_err_t rt_thread_idle_delhook(void (*hook)(void));

Check failure on line 439 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`delhook` is not a recognized word. (unrecognized-spelling)
```

Input parameters and return values of setting idle hook function `rt_thread_idle_sethook()` are as shown in the following table:
Expand All @@ -455,7 +454,7 @@
|--------------|----------------|
| hook | Deleted hook function. |
|**Return** | —— |
| RT_EOK | Successfully deleted. |

Check warning on line 457 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`EOK` is not a recognized word -- found 11 times. (limited-references)
| \-RT_ENOSYS | Failed to delete. |

>An idle thread is a thread whose state is always ready. Therefore, hook function must ensure that idle threads will not be suspended at any time. Functions like rt_thread_delay(), rt_sem_take(), etc can't be used because they may cause the thread to suspend.
Expand Down Expand Up @@ -742,7 +741,7 @@
tid2 = rt_thread_create("thread2",
thread_entry, (void*)2,
THREAD_STACK_SIZE,
THREAD_PRIORITY,THREAD_TIMESLICE - 5);

Check warning on line 744 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`TIMESLICE` is not a recognized word -- found 9 times. (limited-references)
if (tid2 != RT_NULL)
rt_thread_startup(tid2);
return 0;
Expand All @@ -760,7 +759,7 @@
/ | \ 3.1.0 build Aug 27 2018
2006 - 2018 Copyright by rt-thread team
msh > scheduler_hook
msh >from: tshell --> to: thread1

Check warning on line 762 in documentation/thread/thread.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`msh` is not a recognized word -- found 9 times. (limited-references)
thread 1 is running
from: thread1 --> to: thread2
thread 2 is running
Expand Down
2 changes: 1 addition & 1 deletion examples/libc/ex6.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <pthread.h>
#include <unistd.h>

#define usleep rt_thread_sleep
#define usleep rt_thread_delay

static void *test_thread(void *v_param) {
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion examples/libc/ex7.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <sys/time.h>
#include <unistd.h>

#define usleep rt_thread_sleep
#define usleep rt_thread_delay

/* Our event variable using a condition variable contruct. */
typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/libc/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ FINSH_FUNCTION_EXPORT(libc_lseek, lseek test for libc);

void sleep(int tick)
{
rt_thread_sleep(tick);
rt_thread_delay(tick);
}

int libc_fseek(void)
Expand Down
Loading