Skip to content
Open
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
4 changes: 4 additions & 0 deletions jdk/src/linux/classes/com/alibaba/wisp/engine/TimeOut.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
public class TimeOut {
enum Action {
INIT,
JVM_UNPARK,
JDK_UNPARK,
RESUME
Expand Down Expand Up @@ -67,6 +68,9 @@ public boolean expired() {
*/
void doAction() {
switch (action) {
case INIT:
// only be called in Wisp init process
break;
case RESUME:
task.carrier.wakeupTask(task);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public void run() {
new ConcurrentLinkedQueue<>().iterator();
new ConcurrentSkipListMap<>().keySet().iterator();
WispCarrier carrier = WispCarrier.current();
carrier.addTimer(System.nanoTime() + Integer.MAX_VALUE, TimeOut.Action.JDK_UNPARK);
// This timer will never be processed
carrier.addTimer(System.nanoTime() + Integer.MAX_VALUE, TimeOut.Action.INIT);
WispCarrier.current().current.timeOut.doAction();
carrier.cancelTimer();
carrier.createResumeEntry(new WispTask(carrier, null, false, false));
Expand Down
37 changes: 37 additions & 0 deletions jdk/test/com/alibaba/wisp2/MainThreadSleepTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2026 Alibaba Group Holding Limited. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Alibaba designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

public class MainThreadSleepTest {
public static void main(String[] args) throws Exception {
long start = System.nanoTime();
// sleep for 10 seconds
Thread.sleep(10 * 1000);
long end = System.nanoTime();
if (end - start < 10 * 1000000000L) {
System.err.println("sleep time is less than 10 seconds: " + (end - start) + " ns");
System.exit(1);
}
return;
}
}



49 changes: 49 additions & 0 deletions jdk/test/com/alibaba/wisp2/mainThreadSleepTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2026 Alibaba Group Holding Limited. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Alibaba designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#

# @test
# @run shell mainThreadSleepTest.sh
# @summary Main thread sleep time test

OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | AIX )
PS=":"
FS="/"
;;
CYGWIN* )
PS=";"
FS="/"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac

# compile
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSPATH} ${TESTSRC}${FS}MainThreadSleepTest.java

# run
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 -cp ${TESTCLASSPATH} MainThreadSleepTest