Check-in [d26777b957]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Migrate sleep system call.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d26777b957f48f60c5b5d948edb68b99bb9fec2a
User & Date: stephanie.gawroriski 2019-10-06 16:05:28
Context
2019-10-06
16:14
Add sleep to SummerCoat. check-in: 385dc4f7e2 user: stephanie.gawroriski tags: trunk
16:05
Migrate sleep system call. check-in: d26777b957 user: stephanie.gawroriski tags: trunk
14:31
Move structure definitions to other file. check-in: 420f721914 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/Assembly.java.

1462
1463
1464
1465
1466
1467
1468

1469
1470
1471
1472
1473
1474
1475
....
1685
1686
1687
1688
1689
1690
1691
















1692
1693
1694
1695
1696
1697
1698
						case SystemCallIndex.EXIT:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:

						case SystemCallIndex.TIME_HI_MILLI_WALL:
						case SystemCallIndex.TIME_HI_NANO_MONO:
						case SystemCallIndex.TIME_LO_MILLI_WALL:
						case SystemCallIndex.TIME_LO_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
................................................................................
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
















			
				// Current wall clock milliseconds (low).
			case SystemCallIndex.TIME_LO_MILLI_WALL:
				{
					rv = (int)(System.currentTimeMillis());
					err = 0;
				}







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
....
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
						case SystemCallIndex.EXIT:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.TIME_HI_MILLI_WALL:
						case SystemCallIndex.TIME_HI_NANO_MONO:
						case SystemCallIndex.TIME_LO_MILLI_WALL:
						case SystemCallIndex.TIME_LO_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
................................................................................
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
			
				// Current wall clock milliseconds (low).
			case SystemCallIndex.TIME_LO_MILLI_WALL:
				{
					rv = (int)(System.currentTimeMillis());
					err = 0;
				}

Changes to ratufacoat/sjmecon.h.

473
474
475
476
477
478
479



480
481
482
483
484
485
486
487
488
...
501
502
503
504
505
506
507



508
509
510
511
512
513
514

/** Get task ID for current frame. */
#define SJME_SYSCALL_FRAME_TASK_ID_GET SJME_JINT_C(33)

/** Perform device feedback. */
#define SJME_SYSCALL_DEVICE_FEEDBACK SJME_JINT_C(34)




/** System call count. */
#define SJME_SYSCALL_NUM_SYSCALLS SJME_JINT_C(35)

/*****************************************************************************
************************** SYSTEM CALL ERROR CODES ***************************
*****************************************************************************/

/** No error, or success. */
#define SJME_SYSCALL_ERROR_NO_ERROR SJME_JINT_C(0)
................................................................................

/** There is no framebuffer. */
#define SJME_SYSCALL_ERROR_NO_FRAMEBUFFER SJME_JINT_C(-5)

/** Permission denied. */
#define SJME_SYSCALL_ERROR_PERMISSION_DENIED SJME_JINT_C(-6)




/*****************************************************************************
***************************** PIPE DESCRIPTORS *******************************
*****************************************************************************/

/** Pipe descriptor for standard output. */
#define SJME_PIPE_FD_STDOUT SJME_JINT_C(1)








>
>
>

|







 







>
>
>







473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
...
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520

/** Get task ID for current frame. */
#define SJME_SYSCALL_FRAME_TASK_ID_GET SJME_JINT_C(33)

/** Perform device feedback. */
#define SJME_SYSCALL_DEVICE_FEEDBACK SJME_JINT_C(34)

/** Sleeps for the given number of millseconds and nanoseconds. */
#define SJME_SYSCALL_SLEEP SJME_JINT_C(35)

/** System call count. */
#define SJME_SYSCALL_NUM_SYSCALLS SJME_JINT_C(36)

/*****************************************************************************
************************** SYSTEM CALL ERROR CODES ***************************
*****************************************************************************/

/** No error, or success. */
#define SJME_SYSCALL_ERROR_NO_ERROR SJME_JINT_C(0)
................................................................................

/** There is no framebuffer. */
#define SJME_SYSCALL_ERROR_NO_FRAMEBUFFER SJME_JINT_C(-5)

/** Permission denied. */
#define SJME_SYSCALL_ERROR_PERMISSION_DENIED SJME_JINT_C(-6)

/** Interrupted. */
#define SJME_SYSCALL_ERROR_INTERRUPTED SJME_JINT_C(-7)

/*****************************************************************************
***************************** PIPE DESCRIPTORS *******************************
*****************************************************************************/

/** Pipe descriptor for standard output. */
#define SJME_PIPE_FD_STDOUT SJME_JINT_C(1)

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallError.java.

39
40
41
42
43
44
45




46
47
48
49
50
51
52
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;




	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()







>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;
	
	/** Interrupted. */
	public static final byte INTERRUPTED =
		-7;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallIndex.java.

361
362
363
364
365
366
367










368
369
370
371
372
373
374
375
376
377
	 * @param 1 The type of feedback to perform.
	 * @param 2 The duration of the feedback.
	 * @return Non-zero on success.
	 */
	public static final byte DEVICE_FEEDBACK =
		34;
	










	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		35;
}








>
>
>
>
>
>
>
>
>
>










361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
	 * @param 1 The type of feedback to perform.
	 * @param 2 The duration of the feedback.
	 * @return Non-zero on success.
	 */
	public static final byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * @param 1 The number of milliseconds to sleep for.
	 * @param 2 The number of nanoseconds to sleep for.
	 * @return Returns zero unless sleep was interrupted.
	 */
	public static final byte SLEEP =
		35;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		35;
}

Changes to runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/TaskAccess.java.

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void signalInterrupt(int __tid);
	
	/**
	 * Causes the thread to sleep for the given milliseconds and nanoseconds.
	 *
	 * If both values are zero this means to yield instead.
	 *
	 * @param __ms The milliseconds to sleep for.
	 * @param __ns The nanoseconds to sleep for, in the range of 0-999999.
	 * @return {@code true} if the thread was interrupted, otherwise
	 * {@code false}.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native boolean sleep(long __ms, int __ns);
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could







<
<
<
<
<
<
<
<
<
<
<
<
<
<







65
66
67
68
69
70
71














72
73
74
75
76
77
78
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void signalInterrupt(int __tid);
	














	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could

Changes to runt/apis/cldc-compact/java/lang/Thread.java.

590
591
592
593
594
595
596
597
598
599




600


601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
	public static void sleep(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ23 Invalid sleep arguments.}
		if (__ms < 0 || __ns < 0 || __ns > 999999)
			throw new IllegalArgumentException("ZZ23");
		
		// {@squirreljme.error ZZ24 Sleep was interrupted.}
		if (TaskAccess.sleep(__ms, __ns))
		{




			Thread.currentThread()._interrupted = false;


			throw new InterruptedException("ZZ24");
		}
	}
	
	/**
	 * Yields the current thread giving up its execution slice, but allowing
	 * it to continue instantly resuming as needed.
	 *
	 * @since 2018/12/05
	 */
	public static void yield()
	{
		// Zero times means to yield
		TaskAccess.sleep(0, 0);
	}
	
	/**
	 * Registers this thread so that way it is in the thread list and can be
	 * obtained and such.
	 *
	 * @since 2018/12/03







|
|
|
>
>
>
>

>
>













|







590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
	public static void sleep(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ23 Invalid sleep arguments.}
		if (__ms < 0 || __ns < 0 || __ns > 999999)
			throw new IllegalArgumentException("ZZ23");
		
		// Convert to integer but do not sleep for too long
		int ims = (__ms > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)__ms);
		
		// Perform sleep, if it was interrupted then the return status will
		// be non-zero!
		if (Assembly.sysCallV(SystemCallIndex.SLEEP, ims, __ns) != 0)
		{
			Thread.currentThread()._interrupted = false;
			
			// {@squirreljme.error ZZ24 Sleep was interrupted.}
			throw new InterruptedException("ZZ24");
		}
	}
	
	/**
	 * Yields the current thread giving up its execution slice, but allowing
	 * it to continue instantly resuming as needed.
	 *
	 * @since 2018/12/05
	 */
	public static void yield()
	{
		// Zero times means to yield
		Assembly.sysCallV(SystemCallIndex.SLEEP, 0, 0);
	}
	
	/**
	 * Registers this thread so that way it is in the thread list and can be
	 * obtained and such.
	 *
	 * @since 2018/12/03

Changes to runt/klib/supervisor/cc/squirreljme/jvm/SystemCallError.java.

39
40
41
42
43
44
45




46
47
48
49
50
51
52
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;




	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()







>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;
	
	/** Interrupted. */
	public static final byte INTERRUPTED =
		-7;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()

Changes to runt/klib/supervisor/cc/squirreljme/jvm/SystemCallIndex.java.

307
308
309
310
311
312
313
314


315
316
317
318
319
320
321
322
323
324
325
326
327


328
329
330
331
332
333
334
335
336
...
347
348
349
350
351
352
353




















354
355
356
357
358
359
360
361
362
363
	 * @param 1 A byte array encoded in UTF-8 which contains the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor register.


	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @param 1 The supervisor register to set.
	 * @param 2 The new value of the register.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor register.
	 *


	 * @param 1 The supervisor register to get.
	 * @return The value of that register, error should be checked to ensure
	 * that it did not fail.
	 */
	public static final byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
................................................................................
	 * Gets the value of a thread register.
	 *
	 * @return The value of the task ID.
	 */
	public static final byte FRAME_TASK_ID_GET =
		33;
	




















	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		34;
}








|
>
>



|
|






|

>
>
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|


307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
	 * @param 1 A byte array encoded in UTF-8 which contains the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @param 1 The supervisor property to set.
	 * @param 2 The new value of the property.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @param 1 The supervisor property to get.
	 * @return The value of that property, error should be checked to ensure
	 * that it did not fail.
	 */
	public static final byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
................................................................................
	 * Gets the value of a thread register.
	 *
	 * @return The value of the task ID.
	 */
	public static final byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @param 1 The type of feedback to perform.
	 * @param 2 The duration of the feedback.
	 * @return Non-zero on success.
	 */
	public static final byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * @param 1 The number of milliseconds to sleep for.
	 * @param 2 The number of nanoseconds to sleep for.
	 * @return Returns zero unless sleep was interrupted.
	 */
	public static final byte SLEEP =
		35;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		35;
}

Changes to runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringThreadWorker.java.

4104
4105
4106
4107
4108
4109
4110

4111
4112
4113
4114
4115
4116
4117
....
4415
4416
4417
4418
4419
4420
4421
















4422
4423
4424
4425
4426
4427
4428
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:

						case SystemCallIndex.TIME_HI_MILLI_WALL:
						case SystemCallIndex.TIME_HI_NANO_MONO:
						case SystemCallIndex.TIME_LO_MILLI_WALL:
						case SystemCallIndex.TIME_LO_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
................................................................................
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
















			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
....
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.TIME_HI_MILLI_WALL:
						case SystemCallIndex.TIME_HI_NANO_MONO:
						case SystemCallIndex.TIME_LO_MILLI_WALL:
						case SystemCallIndex.TIME_LO_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
................................................................................
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used