FreeBSD Bugzilla – Attachment 146158 Details for
Bug 192918
[patch] A thread will spin if a signal interrupts umtxq_sleep_pi.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case
umtx_suspend.c (text/x-c), 1.69 KB, created by
eric
on 2014-08-22 15:10:32 UTC
(
hide
)
Description:
Test case
Filename:
MIME Type:
Creator:
eric
Created:
2014-08-22 15:10:32 UTC
Size:
1.69 KB
patch
obsolete
>// cc -lpthread -o umtx_suspend umtx_suspend.c >// >// failure: a thread spins around "umtxpi" the kernel, ignoring signals >// success: the process exits > >#include <sys/cdefs.h> > >#include <err.h> >#include <pthread.h> >#include <pthread_np.h> >#include <stdio.h> >#include <unistd.h> > >pthread_mutex_t the_mutex; > >void * >spinning_thread_func(void *arg __unused) >{ > int error; > > error = pthread_mutex_lock(&the_mutex); > if (error) > errc(1, error, "%s: pthread_mutex_lock", __func__); > > return (NULL); >} > >int >main(int argc __unused, char *argv[] __unused) >{ > int error; > pthread_t spinning_thread; > pthread_mutexattr_t the_mutex_attr; > > error = pthread_mutexattr_init(&the_mutex_attr); > if (error) > errc(1, error, "pthread_mutexattr_init"); > > error = pthread_mutexattr_setprotocol(&the_mutex_attr, PTHREAD_PRIO_INHERIT); > if (error) > errc(1, error, "pthread_mutexattr_setprotocol"); > > error = pthread_mutex_init(&the_mutex, &the_mutex_attr); > if (error) > errc(1, error, "pthread_mutex_init"); > > error = pthread_mutex_lock(&the_mutex); > if (error) > errc(1, error, "pthread_mutex_lock"); > > error = pthread_create(&spinning_thread, NULL, spinning_thread_func, NULL); > if (error) > errc(1, error, "pthread_create"); > > // Wait for the spinning_thread to call pthread_mutex_lock(3) > // and enter the kernel. > (void) sleep(1); > > error = pthread_suspend_np(spinning_thread); > if (error) > errc(1, error, "pthread_suspend_np"); > > // The spinning_thread should be spinning in the kernel. > // This thread should be blocked in pthread_suspend_np(3). > fputs("This test failed to reproduce the bug.\n", stderr); > > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 192918
: 146158 |
146159