Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 217981 Details for
Bug 219891
xen SDL framebuffer uses busy polling loop
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to convert the sdlfb busy looping with a thread implementation
xen-sdlfb-thread.patch (text/plain), 3.88 KB, created by
Chris Lalancette
on 2007-10-05 20:40:12 UTC
(
hide
)
Description:
Patch to convert the sdlfb busy looping with a thread implementation
Filename:
MIME Type:
Creator:
Chris Lalancette
Created:
2007-10-05 20:40:12 UTC
Size:
3.88 KB
patch
obsolete
>diff -urp xen-3.1.0-src.orig/tools/xenfb/Makefile xen-3.1.0-src/tools/xenfb/Makefile >--- xen-3.1.0-src.orig/tools/xenfb/Makefile 2007-10-05 16:34:51.000000000 -0400 >+++ xen-3.1.0-src/tools/xenfb/Makefile 2007-10-05 16:35:51.000000000 -0400 >@@ -22,7 +22,7 @@ install: all > sdlfb: sdlfb.o xenfb.o > > sdlfb.o: CFLAGS += $(shell sdl-config --cflags) >-sdlfb: LDLIBS += $(shell sdl-config --libs) -lxenctrl -lxenstore >+sdlfb: LDLIBS += $(shell sdl-config --libs) -lxenctrl -lxenstore -lpthread > > clean: > $(RM) *.o *~ vncfb sdlfb >diff -urp xen-3.1.0-src.orig/tools/xenfb/sdlfb.c xen-3.1.0-src/tools/xenfb/sdlfb.c >--- xen-3.1.0-src.orig/tools/xenfb/sdlfb.c 2007-10-05 16:34:51.000000000 -0400 >+++ xen-3.1.0-src/tools/xenfb/sdlfb.c 2007-10-05 16:35:47.000000000 -0400 >@@ -6,8 +6,13 @@ > #include <linux/input.h> > #include <getopt.h> > #include <string.h> >+#include <pthread.h> >+#include <unistd.h> > #include "xenfb.h" > >+static int sdlevents[2]; >+static pthread_mutex_t xenfb_mutex = PTHREAD_MUTEX_INITIALIZER; >+ > struct SDLFBData > { > SDL_Surface *dst; >@@ -207,6 +212,31 @@ static struct option options[] = { > { NULL } > }; > >+void sdleventsthread(void *args) >+{ >+ char buf[1]; >+ int do_quit, eventret; >+ SDL_Event event; >+ struct xenfb *xenfb; >+ >+ xenfb = (struct xenfb *)args; >+ do_quit = 0; >+ >+ for (;;) { >+ while (SDL_PollEvent(&event)) { >+ pthread_mutex_lock(&xenfb_mutex); >+ eventret = sdl_on_event(xenfb, &event); >+ pthread_mutex_unlock(&xenfb_mutex); >+ if (!eventret) >+ do_quit = 1; >+ } >+ if (do_quit) { >+ write(sdlevents[1], buf, 1); >+ break; >+ } >+ } >+} >+ > int main(int argc, char **argv) > { > struct xenfb *xenfb; >@@ -217,12 +247,12 @@ int main(int argc, char **argv) > int nfds; > struct SDLFBData data; > SDL_Rect r; >- struct timeval tv; >- SDL_Event event; > int do_quit = 0; > int opt; > char *endp; > int retval; >+ pthread_t threadpid; >+ char dummy[1]; > > while ((opt = getopt_long(argc, argv, "d:t:", options, > NULL)) != -1) { >@@ -310,39 +340,63 @@ int main(int argc, char **argv) > > /* > * We need to wait for fds becoming ready or SDL events to >- * arrive. We time out the select after 10ms to poll for SDL >- * events. Clunky, but works. Could avoid the clunkiness >- * with a separate thread. >+ * arrive. Spawn another thread to poll for SDL events and send them >+ * back our way over a pipe. Kind of clunky, but less so than busy >+ * polling. > */ >+ if (pipe(sdlevents) < 0) { >+ fprintf(stderr, "Error creating pipe for SDL events\n"); >+ exit(2); >+ } >+ >+ pthread_create(&threadpid, NULL, (void *)&sdleventsthread, xenfb); >+ > for (;;) { > FD_ZERO(&readfds); >+ pthread_mutex_lock(&xenfb_mutex); > nfds = xenfb_select_fds(xenfb, &readfds); >- tv = (struct timeval){0, 10000}; >- >- if (select(nfds, &readfds, NULL, NULL, &tv) < 0) { >+ pthread_mutex_unlock(&xenfb_mutex); >+ FD_SET(sdlevents[0], &readfds); >+ nfds++; >+ >+ if (select(nfds, &readfds, NULL, NULL, NULL) < 0) { > if (errno == EINTR) > continue; > fprintf(stderr, > "Can't select() on event channel (%s)\n", > strerror(errno)); >+ do_quit = 1; > break; > } >- >- while (SDL_PollEvent(&event)) { >- if (!sdl_on_event(xenfb, &event)) >- do_quit = 1; >+ >+ if (FD_ISSET(sdlevents[0], &readfds)) { >+ read(sdlevents[0], dummy, 1); >+ do_quit = 1; > } >- >+ > if (do_quit) >+ /* Don't need to pthread_cancel here, since it was >+ * the thread itself that told us to quit */ > break; >- >+ >+ pthread_mutex_lock(&xenfb_mutex); > retval = xenfb_poll(xenfb, &readfds); >- if (retval == -2) >- xenfb_teardown(xenfb); >- if (retval < 0) >- break; >+ pthread_mutex_unlock(&xenfb_mutex); >+ if (retval == -2) { >+ pthread_mutex_lock(&xenfb_mutex); >+ xenfb_teardown(xenfb); >+ pthread_mutex_unlock(&xenfb_mutex); >+ } >+ if (retval < 0) { >+ pthread_cancel(threadpid); >+ break; >+ } > } > >+ pthread_join(threadpid, NULL); >+ close(sdlevents[0]); >+ close(sdlevents[1]); >+ > xenfb_delete(xenfb); > > SDL_Quit();
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 219891
: 217981