Patchwork [08/13] Remove thread_create routine.

login
register
mail settings
Submitter Arun Bharadwaj
Date Jan. 4, 2011, 5:27 a.m.
Message ID <20110104052749.15887.35027.stgit@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/77387/
State New
Headers show

Comments

Arun Bharadwaj - Jan. 4, 2011, 5:27 a.m.
Remove thread_create and use qemu_thread_create instead.

Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
---
 posix-aio-compat.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)
Stefan Hajnoczi - Jan. 5, 2011, 7:56 p.m.
On Tue, Jan 04, 2011 at 10:57:49AM +0530, Arun R Bharadwaj wrote:
> Remove thread_create and use qemu_thread_create instead.
> 
> Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
> ---
>  posix-aio-compat.c |   19 ++-----------------
>  1 files changed, 2 insertions(+), 17 deletions(-)
> 

Can we remove #include <pthread.h> now?

Stefan
Arun Bharadwaj - Jan. 7, 2011, 5:59 a.m.
* Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> [2011-01-05 19:56:00]:

> On Tue, Jan 04, 2011 at 10:57:49AM +0530, Arun R Bharadwaj wrote:
> > Remove thread_create and use qemu_thread_create instead.
> > 
> > Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
> > ---
> >  posix-aio-compat.c |   19 ++-----------------
> >  1 files changed, 2 insertions(+), 17 deletions(-)
> > 
> 
> Can we remove #include <pthread.h> now?
> 

Yes we can now remove this.

> Stefan

Patch

diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index fd9fcfd..3b01c9b 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -83,7 +83,6 @@  typedef struct PosixAioState {
 /* Default ThreadletQueue */
 static ThreadletQueue globalqueue;
 static int globalqueue_init;
-static pthread_attr_t attr;
 
 #ifdef CONFIG_PREADV
 static int preadv_present = 1;
@@ -102,13 +101,6 @@  static void die(const char *what)
     die2(errno, what);
 }
 
-static void thread_create(pthread_t *thread, pthread_attr_t *attr,
-                          void *(*start_routine)(void*), void *arg)
-{
-    int ret = pthread_create(thread, attr, start_routine, arg);
-    if (ret) die2(ret, "pthread_create");
-}
-
 static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
 {
     int ret;
@@ -375,19 +367,12 @@  static void aio_thread(ThreadletWork *work)
 
 static void spawn_threadlet(ThreadletQueue *queue)
 {
-    pthread_t thread_id;
-    sigset_t set, oldset;
+    QemuThread thread;
 
     queue->cur_threads++;
     queue->idle_threads++;
 
-    /* block all signals */
-    if (sigfillset(&set)) die("sigfillset");
-    if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask");
-
-    thread_create(&thread_id, &attr, threadlet_worker, queue);
-
-    if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore");
+    qemu_thread_create(&thread, threadlet_worker, queue);
 }