Skip to content

Commit

Permalink
Linux (& unix/Mac OS X):
Browse files Browse the repository at this point in the history
Fix the build of the XDisplayControlPlugin on linuxes where .so is not appended
to shared objects.
Fix the language in sqUnixHeartbeat.c and add more information.  Make the code
exclusive to linux, and use exeName instead of a hardwired name.
  • Loading branch information
eliotmiranda committed Mar 21, 2017
1 parent 32f3215 commit 54bab0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
7 changes: 1 addition & 6 deletions platforms/unix/plugins/XDisplayControlPlugin/Makefile.inc
@@ -1,8 +1,3 @@
XCPPFLAGS= -I$(topdir)/platforms/Cross/plugins/FilePlugin -I$(topdir)/platforms/Cross/plugins/SocketPlugin
XINCLUDES= $(X_INCLUDES)
XLDFLAGS= $(X_LIBS) -L. -lvm-display-X11

$(TARGET): libvm-display-X11.so

libvm-display-X11.so:
ln -s ../vm-display-X11/.libs/vm-display-X11.so libvm-display-X11.so
XLDFLAGS= $(X_LIBS) -L ../vm-display-X11/.libs -lvm-display-X11
35 changes: 19 additions & 16 deletions platforms/unix/vm/sqUnixHeartbeat.c
Expand Up @@ -297,42 +297,45 @@ static volatile machine_state beatState = nascent;
static int beatMilliseconds = DEFAULT_BEAT_MS;
static struct timespec beatperiod = { 0, DEFAULT_BEAT_MS * 1000 * 1000 };

#if __linux__
# include "sqUnixMain.h"
#endif

static void *
beatStateMachine(void *careLess)
{
int er;
if ((er = pthread_setschedparam(pthread_self(),
stateMachinePolicy,
&stateMachinePriority))) {
extern char *revisionAsString();
errno = er;
perror("pthread_setschedparam failed");
#if __linux__
/* Linux pthreads as of 2009 does not support setting the priority of
* threads other than with real-time scheduling policies. But such
* policies are only available to processes with superuser privileges.
* Linux kernels >= 2.6.13 support different thread priorities, but
* require a suitable /etc/security/limits.d/VMNAME.conf.
*/
extern char *revisionAsString();
errno = er;
perror("pthread_setschedparam failed");
#if PharoVM
# define VMNAME "pharo"
#elif NewspeakVM
# define VMNAME "nsvm"
#else
# define VMNAME "squeak"
#endif
fprintf(stderr, "This VM uses a thread heartbeat who requires a special configuration to work.\n");
fprintf(stderr, "You need to allow it to run higher priority threads (real time), to allow clock to work properly\n");
fprintf(stderr, "You need to add a conf file to /etc/security/limits.d, executing this:\n\n");
fprintf(stderr, "sudo cat >/etc/security/limits.d/%s.conf <<END\n", VMNAME);
fprintf(stderr, "This VM uses a heartbeat thread which requires a special configuration to work.\n");
fprintf(stderr, "It must be allowed to run higher priority threads for the clock and interrupts\n");
fprintf(stderr, "to work properly. To do this, add a conf file to /etc/security/limits.d by\n");
fprintf(stderr,"executing this:\n\n");
fprintf(stderr, "sudo cat >/etc/security/limits.d/%s.conf <<END\n", exeName);
fprintf(stderr, "* hard rtprio 2\n");
fprintf(stderr, "* soft rtprio 2\n");
fprintf(stderr, "END\n");
fprintf(stderr, "\nYou need to log out and log back in for the limits to take effect.\n");
fprintf(stderr, "For more information read https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/tag/r3732#linux\n");
fprintf(stderr, "\nLog out and back in for the limits to take effect. For more information read\n");
fprintf(stderr, " https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/tag/r3732#linux\n");
fprintf(stderr, " http://forum.world.st/Unix-heartbeat-thread-vs-itimer-td4928943.html\n");
// The VM may have issues with clock jitter due to the heartbeat thread
// not running at elevated priority. An exit may be appropriate in some
// cases, but for most users the above warning is sufficient.
// exit(errno);
#else
exit(errno);
#endif
}
beatState = active;
while (beatState != condemned) {
Expand Down

0 comments on commit 54bab0a

Please sign in to comment.