Thread Pool Implementation in Bionet Platform - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Thread Pool Implementation in Bionet Platform

Description:

Jun Suzuki, Michael Le and Tatsuya Suda {jsuzuki, suda}_at_ics.uci.edu. mvle_at_uci.edu ... In order for the Bionet Platform to maintain and ensure a high level of ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 7
Provided by: jsuz
Category:

less

Transcript and Presenter's Notes

Title: Thread Pool Implementation in Bionet Platform


1
Thread Pool Implementationin Bionet
Platform Dec. 17, 2002
Jun Suzuki, Michael Le and Tatsuya
Suda jsuzuki, suda_at_ics.uci.edu mvle_at_uci.eduhtt
p//netresearch.ics.uci.edu/bionet/ Dept. of
Information and Computer ScienceUniversity of
California, Irvine
2
Motivations to Thread Pool
  • In order for the Bionet Platform to maintain and
    ensure a high level of performance, a threadpool
    with a predefined number of threads must be
    available.
  • The threadpool can guarantee the maximum number
    of threads and, therefore, the maximum number of
    CEs running on the system at any given time.
  • Each autonomous CyberEntity runs on a separate
    thread
  • A CE wishing to be autonomous will have to wait
    and be queued in the pool until there is an
    available thread for it to use.

3
Threads in Thread Pool
  • A threadpool has a specified number of threads.
  • Threads are started up running in a continuous
    loop
  • Each idle thread will try continuously to obtain
    a runnable object
  • (CE) and invoke the start() method on it.
  • Until the CE start() operation returns, the
    thread is no longer idle
  • The runnable objects (CEs) are queued up in a
    queue when there are
  • no more threads for the CEs to use.
  • The two methods in the queue are
  • synchronized public object get()
  • synchronized public put(Object obj)
  • If there is no runnable object queued up, then
    the thread
  • is forced to wait in the get() operation
  • Otherwise if there is at least one runnable
    object in the queue,
  • then a thread can obtain that runnable object

4
ThreadPool Class Definition
  • package edu.uci.ics.bionet.util.threadpool.ThreadP
    ool
  • public class ThreadPool
  • void execute(Runnable runnable)
  • static ThreadPool getInstance(int MaxThreadNum)
  • Runnable getNextRunnable()
  • int getNumberOfIdleThreads()
  • int getThreadPoolSize()           
  • int getWaitingRunnableQueueSize()           
  • void setMaxThreadNum(int MaxThreadNum)

5
NoIdleThreadException
  • This exception is thrown when there is no more
    idle thread in the thread pool
  • Potential problem of throwing this exception.
  • Different call back methods may have already been
    called, some will perform actions and some will
    change the state of the CE. It is necessary that
    this exception makes sure that the state of the
    CE is still consistent with the actual state of
    the CE, and if necessary, revert back to any
    conditions prior to the exception being thrown.

6
Insert CE Into Thread PoolPotential Problem
  • The problem arises when a CE has already changed
    its state to autonomous but have not yet received
    a free thread and enter the thread pool to
    execute its run loop and is still waiting the the
    thread pool queue.
  • During this queuing process that the CE is
    waiting for a free thread from the thread pool,
    the state of this particular CE is autonomous.
    This state is missed report and may affect other
    services like Energy Management services that
    will tally energy gain and expenditure and decide
    the results thereof, based on information like
    the CEs state.
  • In the current design of LifeCycleService, this
    problem is alleviated. Since a CE can only
    change its state when there is an idle thread in
    the pool. If there is no idle thread, then the
    exception NoIdleThreadException would have been
    thrown and the code to change the state of the CE
    to autonomous would not have been executed.
  • In the current design, the state of CE is
    considered autonomous when queuing to wait for a
    free thread from the pool
Write a Comment
User Comments (0)
About PowerShow.com