[PATCH v2 11/15] bsd-user: Add stop_all_tasks

Warner Losh posted 15 patches 4 years, 4 months ago
[PATCH v2 11/15] bsd-user: Add stop_all_tasks
Posted by Warner Losh 4 years, 4 months ago
Similar to the same function in linux-user: this stops all the current tasks.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/main.c | 9 +++++++++
 bsd-user/qemu.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index ee84554854..cb5ea40236 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -195,6 +195,15 @@ static void usage(void)
 
 __thread CPUState *thread_cpu;
 
+void stop_all_tasks(void)
+{
+    /*
+     * We trust when using NPTL (pthreads) start_exclusive() handles thread
+     * stopping correctly.
+     */
+    start_exclusive();
+}
+
 bool qemu_cpu_is_self(CPUState *cpu)
 {
     return thread_cpu == cpu;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index c1170f14d9..cdb85140f4 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -103,6 +103,7 @@ typedef struct TaskState {
 } __attribute__((aligned(16))) TaskState;
 
 void init_task_state(TaskState *ts);
+void stop_all_tasks(void);
 extern const char *qemu_uname_release;
 
 /*
-- 
2.32.0


Re: [PATCH v2 11/15] bsd-user: Add stop_all_tasks
Posted by Richard Henderson 4 years, 4 months ago
On 10/8/21 4:15 PM, Warner Losh wrote:
> Similar to the same function in linux-user: this stops all the current tasks.
> 
> Signed-off-by: Stacey Son<sson@FreeBSD.org>
> Signed-off-by: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/main.c | 9 +++++++++
>   bsd-user/qemu.h | 1 +
>   2 files changed, 10 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

Re: [PATCH v2 11/15] bsd-user: Add stop_all_tasks
Posted by Kyle Evans 4 years, 3 months ago
On Fri, Oct 8, 2021 at 6:15 PM Warner Losh <imp@bsdimp.com> wrote:
>
> Similar to the same function in linux-user: this stops all the current tasks.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>  bsd-user/main.c | 9 +++++++++
>  bsd-user/qemu.h | 1 +
>  2 files changed, 10 insertions(+)
>
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index ee84554854..cb5ea40236 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -195,6 +195,15 @@ static void usage(void)
>
>  __thread CPUState *thread_cpu;
>
> +void stop_all_tasks(void)
> +{
> +    /*
> +     * We trust when using NPTL (pthreads) start_exclusive() handles thread
> +     * stopping correctly.
> +     */
> +    start_exclusive();
> +}
> +
>  bool qemu_cpu_is_self(CPUState *cpu)
>  {
>      return thread_cpu == cpu;
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index c1170f14d9..cdb85140f4 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -103,6 +103,7 @@ typedef struct TaskState {
>  } __attribute__((aligned(16))) TaskState;
>
>  void init_task_state(TaskState *ts);
> +void stop_all_tasks(void);
>  extern const char *qemu_uname_release;
>
>  /*
> --
> 2.32.0
>

Reviewed-by: Kyle Evans <kevans@FreeBSD.org>