Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

timeslice.c File Reference


Detailed Description

JVM one millisecond time slice timer.

The pjvm->timeslice_expired flag is set by the periodic SIGALRM herein and tested in the JVM virtual instruction inner loop to decide when a thread has finished using its time slice.

   function              flag value             meaning
   --------              ----------             -------
  
   timeslice_init()      set rfalse             initial value
  
   timeslice_tick()      set rtrue              time slice finished
  
   jvm_run()             rfalse                 keep running this slice
                         rtrue                  time slice finished
   

Control

$URL: https://svn.apache.org/path/name/timeslice.c $ $Id: timeslice.c 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file timeslice.c.

#include "arch.h"
#include <unistd.h>
#include <signal.h>
#include <pthread.h>
#include <thread.h>
#include "jvmcfg.h"
#include "classfile.h"
#include "jvm.h"
#include "exit.h"
#include "util.h"

Go to the source code of this file.

Defines

#define _REENTRANT

Functions

static void timeslice_c_dummy (void)
jlong timeslice_get_thread_sleeptime (jvm_thread_index thridx)
 Retrieve a thread's sleeptime value safely during read of that variable on a given thread.
rvoid timeslice_init ()
 Start the time slicing mechanism at JVM init time.
void * timeslice_run (void *dummy)
 Interval timer thread.
rvoid timeslice_shutdown (rvoid)
 Shut down the time slicing mechanism for JVM shutdown.
static void timeslice_tick ()
 Interval timer handler for the signal(SIGALRM) event.

Variables

static pthread_t posix_thread_id
 Thread control structure for use by pthread_create(3), etc.
static char * timeslice_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/timeslice.c $ $Id: timeslice.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable."
static struct itimerval timeslice_period
 Length of time slice interval as used by setitimer(2).


Define Documentation

#define _REENTRANT
 

Definition at line 62 of file timeslice.c.


Function Documentation

static void timeslice_c_dummy void   )  [static]
 

Definition at line 56 of file timeslice.c.

rvoid timeslice_init  ) 
 

Start the time slicing mechanism at JVM init time.

Parameters: rvoid

Returns:
rvoid

Definition at line 89 of file timeslice.c.

References exit_jvm(), EXIT_TIMESLICE_START, jvm_timeslice_initialized, pjvm, posix_thread_id, rfalse, rnull, rtrue, rjvm::sleeplock, sysErrMsg(), rjvm::timeslice_expired, and timeslice_run().

jlong timeslice_get_thread_sleeptime jvm_thread_index  thridx  ) 
 

Retrieve a thread's sleeptime value safely during read of that variable on a given thread.

Parameters:
thridx Thread index of thread to read its sleeptime value
Returns:
remaining sleep time, in timer ticks

Definition at line 133 of file timeslice.c.

References pjvm, rjvm::sleeplock, and THREAD.

Referenced by threadutil_update_wait().

static void timeslice_tick  )  [static]
 

Interval timer handler for the signal(SIGALRM) event.

Parameters: rvoid

Returns:
rvoid
Warning:
Eclipse users need to remember that setting a combination of the value of JVMCFG_TIMESLICE_PERIOD_ENABLE to rtrue, the value of JVMCFG_TIMESLICE_PERIOD_SECONDS to zero (0), and the value of JVMCFG_TIMESLICE_PERIOD_MICROSECONDS to a low milliseconds value is certain to interfere with the proper operation of the GDB debug process due to the high frequency of thread context changes per second. The debug session will terminate without rhyme nor reason. Setting the period to several seconds will elminate this problem at the expense of time slicing on a normal basis. For unit testing, this is not a problem. For integration testing, you are on your own....

Definition at line 187 of file timeslice.c.

References DML9, JVMCFG_TIMESLICE_DEBUG_REPORT_MIN_SECONDS, pjvm, rtrue, sysDbgMsg(), threadutil_update_sleeptime_interval(), rjvm::timeslice_expired, and timeslice_period.

Referenced by timeslice_run().

void* timeslice_run void *  dummy  ) 
 

Interval timer thread.

Parameters:
dummy The setitimer(2) system call requires a (void *) that has no meaning here.
Returns:
The required (void *) is passed back, but this function never returns until the time slice thread is killed.

Definition at line 230 of file timeslice.c.

References exit_jvm(), EXIT_TIMESLICE_START, JVMCFG_TIMESLICE_PERIOD_ENABLE, JVMCFG_TIMESLICE_PERIOD_MICROSECONDS, JVMCFG_TIMESLICE_PERIOD_SECONDS, rnull, rtrue, sysErrMsg(), timeslice_period, and timeslice_tick().

Referenced by timeslice_init().

rvoid timeslice_shutdown rvoid   ) 
 

Shut down the time slicing mechanism for JVM shutdown.

Parameters: rvoid

Returns:
rvoid
Todo:
Is this necessary at JVM shutdown time?

Definition at line 295 of file timeslice.c.

References jvm_timeslice_initialized, posix_thread_id, and rfalse.


Variable Documentation

char* timeslice_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/timeslice.c $ $Id: timeslice.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." [static]
 

Definition at line 56 of file timeslice.c.

pthread_t posix_thread_id [static]
 

Thread control structure for use by pthread_create(3), etc.

Definition at line 77 of file timeslice.c.

Referenced by timeslice_init(), and timeslice_shutdown().

struct itimerval timeslice_period [static]
 

Length of time slice interval as used by setitimer(2).

Definition at line 155 of file timeslice.c.

Referenced by timeslice_run(), and timeslice_tick().


Generated on Fri Sep 30 18:50:35 2005 by  doxygen 1.4.4