Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify MetronomeAlarm for moving into OMR #5162

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 16 additions & 28 deletions runtime/gc_realtime/MetronomeAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,10 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

#include "ProcessorInfo.hpp"
#include "AtomicOperations.hpp"
#include "ClassModel.hpp"
#include "Dispatcher.hpp"
#include "EnvironmentBase.hpp"
#include "GCExtensions.hpp"
#include "Heap.hpp"
#include "MemoryPoolSegregated.hpp"
#include "MemorySubSpace.hpp"
#include "modronapi.hpp"
#include "ObjectModel.hpp"
#include "OSInterface.hpp"
#include "RootScanner.hpp"
#include "Task.hpp"
#include "MetronomeAlarmThread.hpp"
#include "RealtimeGC.hpp"
#include "OSInterface.hpp"
Copy link
Contributor

@dmitripivkine dmitripivkine Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to add #include "Scheduler.hpp" here. It is used in MM_ITAlarm::alarm_handle(). Currently it is resolved through MetronomeAlarmThread.hpp -> EnvironmentRealtime.hpp, but would be better to put it explicitly.

#include "Scheduler.hpp"

#include "MetronomeAlarm.hpp"

Expand Down Expand Up @@ -71,7 +59,7 @@ MM_HRTAlarm::newInstance(MM_EnvironmentBase *env)
{
MM_HRTAlarm * alarm;

alarm = (MM_HRTAlarm *)env->getForge()->allocate(sizeof(MM_HRTAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE());
alarm = (MM_HRTAlarm *)env->getForge()->allocate(sizeof(MM_HRTAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE());
if (alarm) {
new(alarm) MM_HRTAlarm();
}
Expand All @@ -83,7 +71,7 @@ MM_RTCAlarm::newInstance(MM_EnvironmentBase *env)
{
MM_RTCAlarm * alarm;

alarm = (MM_RTCAlarm *)env->getForge()->allocate(sizeof(MM_RTCAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE());
alarm = (MM_RTCAlarm *)env->getForge()->allocate(sizeof(MM_RTCAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE());
if (alarm) {
new(alarm) MM_RTCAlarm();
}
Expand All @@ -95,7 +83,7 @@ MM_ITAlarm::newInstance(MM_EnvironmentBase *env)
{
MM_ITAlarm * alarm;

alarm = (MM_ITAlarm *)env->getForge()->allocate(sizeof(MM_ITAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE());
alarm = (MM_ITAlarm *)env->getForge()->allocate(sizeof(MM_ITAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE());
if (alarm) {
new(alarm) MM_ITAlarm();
}
Expand Down Expand Up @@ -128,7 +116,7 @@ MM_Alarm::factory(MM_EnvironmentBase *env, MM_OSInterface* osInterface)
bool
MM_HRTAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread)
{
_extensions = MM_GCExtensions::getExtensions(env);
_extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM());
return alarmThread->startThread(env);
}

Expand All @@ -145,32 +133,32 @@ MM_HRTAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmT
bool
MM_RTCAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread)
{
_extensions = MM_GCExtensions::getExtensions(env);
_extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM());
#if defined(LINUX) && !defined(J9ZTPF)
PORT_ACCESS_FROM_ENVIRONMENT(env);
OMRPORT_ACCESS_FROM_ENVIRONMENT(env);

RTCfd = open("/dev/rtc", O_RDONLY);
if (RTCfd == -1) {
if (_extensions->verbose >= 2) {
j9tty_printf(PORTLIB, "Unable to open /dev/rtc\n");
omrtty_printf("Unable to open /dev/rtc\n");
}
goto error;
}
if ((ioctl(RTCfd, RTC_IRQP_SET, _extensions->RTC_Frequency) == -1)) {
if (_extensions->verbose >= 2) {
j9tty_printf(PORTLIB, "Unable to set IRQP for /dev/rtc\n");
omrtty_printf("Unable to set IRQP for /dev/rtc\n");
}
goto error;
}
if (ioctl(RTCfd, RTC_IRQP_READ, &_extensions->RTC_Frequency)) {
if (_extensions->verbose >= 2) {
j9tty_printf(PORTLIB, "Unable to read IRQP for /dev/rtc\n");
omrtty_printf("Unable to read IRQP for /dev/rtc\n");
}
goto error;
}
if (ioctl(RTCfd, RTC_PIE_ON, 0) == -1) {
if (_extensions->verbose >= 2) {
j9tty_printf(PORTLIB, "Unable to enable PIE for /dev/rtc\n");
omrtty_printf("Unable to enable PIE for /dev/rtc\n");
}
goto error;
}
Expand All @@ -179,7 +167,7 @@ MM_RTCAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmT

error:
if (_extensions->verbose >= 1) {
j9tty_printf(PORTLIB, "Unable to use /dev/rtc for time-based scheduling\n");
omrtty_printf("Unable to use /dev/rtc for time-based scheduling\n");
}
return false;
#else
Expand Down Expand Up @@ -213,7 +201,7 @@ itAlarmThunk(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PT
bool
MM_ITAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread)
{
_extensions = MM_GCExtensions::getExtensions(env);
_extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM());
if (!alarmThread->startThread(env)) {
return false;
}
Expand Down Expand Up @@ -248,7 +236,7 @@ void
MM_RTCAlarm::sleep()
{
#if defined(LINUX) && !defined(J9ZTPF)
UDATA data;
uintptr_t data;
ssize_t readAmount = read(RTCfd, &data, sizeof(data));
if (readAmount == -1) {
perror("blocking read failed");
Expand All @@ -275,7 +263,7 @@ void MM_RTCAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize)

void MM_HRTAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize) {
OMRPORT_ACCESS_FROM_OMRPORT(port);
omrstr_printf(buffer, bufferSize, "High Resolution Timer (Period = %d us)", _extensions->hrtPeriodMicro);
omrstr_printf(buffer, bufferSize, "High Resolution Timer (Period = %d us)", _extensions->hrtPeriodMicro);
}

void MM_ITAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize) {
Expand Down
8 changes: 4 additions & 4 deletions runtime/gc_realtime/MetronomeAlarm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class MM_EnvironmentBase;
class MM_ProcessorInfo;
class MM_MetronomeAlarmThread;

#include "j9.h"
#include "j9cfg.h"
#include "omr.h"
#include "omrcfg.h"

#include "Base.hpp"
#include "GCExtensions.hpp"
#include "GCExtensionsBase.hpp"

#if defined(WIN32)
#include "omrmutex.h"
Expand Down Expand Up @@ -67,7 +67,7 @@ class MM_Alarm : protected MM_BaseVirtual
}
virtual void tearDown(MM_EnvironmentBase *env);

MM_GCExtensions *_extensions;
MM_GCExtensionsBase *_extensions;

public:
virtual void kill(MM_EnvironmentBase *envModron);
Expand Down