Sol 9 thread scheduling

I posted this yesterday in the kernel forum because thread scheduling seemed more like a kernel issue than the generally admin type things usually discussed here, but I've not had any takers in kernel, so I'm trying here. Basically, while porting an application from solaris 8 to solaris 9, I seem to have run into a starvation issue with the new 1x1 thread model.
Here is a link to the post in the kernel forum:
http://forum.sun.com/thread.jsp?forum=10&thread=18592&tstart=0&trange=100
Any help would be appreciated.

I wonder why results were same. I replaced sleep(10) with an arbitrary number of busy loops, 100000
I do see that all threads get a chance to run. I am running a 2 CPU ultrasparc each running at 1002 MHz. I do not have an understanding of your application though, but as others mentioned feel that mutexes should be used to protect critical sections (which would be small) or as a mechanism to wakeup in an async manner along with condition variables.
pthread_starvation: press ^C to interrupt.
Thread 6 waited 0 milliseconds.
Thread 11 waited 5 milliseconds.
Thread 10 waited 5 milliseconds.
Thread 9 waited 6 milliseconds.
Thread 8 waited 6 milliseconds.
Thread 7 waited 7 milliseconds.
Thread 2 waited 7 milliseconds.
Thread 3 waited 7 milliseconds.
Thread 4 waited 8 milliseconds.
Thread 5 waited 8 milliseconds.
Thread 6 waited 0 milliseconds.
Thread 11 waited 0 milliseconds.
Thread 10 waited 0 milliseconds.
Thread 9 waited 0 milliseconds.
Thread 8 waited 0 milliseconds.
Thread 7 waited 0 milliseconds.
Thread 2 waited 0 milliseconds.
Thread 3 waited 0 milliseconds.
-madhusudan

Similar Messages

  • IS a thread scheduler part of JVM or OS ?

    Hi Folks,
    Just curious if the thread scheduler is a part of the JVM or OS, or either or both ?
    I tried few thread pages in JLS,but couldnot locate the exact sentence describing this.
    However some other resources have given me contradicting information.
    For example, [Reference1|http://www.deitel.com/articles/java_tutorials/20051126/JavaMultithreading_Tutorial_Part3.html] states that it is a part of the OS,whereas [Reference2|http://book.javanb.com/java-threads-3rd/jthreads3-CHP-9-SECT-1.html] states that it is a part of both.(I am not sure about the authority of these links.)
    So assuming, thread scheduling is done by JVM it is a part of the JVM only or it uses the underlying OS for support.
    Thank you for the consideration.

    This statement:
    The JVM ... operates like a mini OS and schedules its own threads regardless the underlying operating system.flatly contradicts this statement:
    In some JVMs, the java threads are actually mapped to native OS threads.They cannot both be true.
    Therefore we can say that Threads are part of JVM and OS bothRubbish. There's no 'therefore' about it. You can't draw valid logical inferences from contradictions.
    Guesswork and invalid inferences aside, the fact of the matter is that the semantics of Java threads are specified in the JLS but the execution mechanism is not. 'Any execution strategy that generates only allowed behaviors is an acceptable execution strategy.'
    I am not sure about the authority of these linksNil. They are extracts from books by third parties. Use at own risk. The JLS is where the authority is.
    Reference 2 is particularly poor, as it contradicts itself numerous times.
    For the record, Reference 2 also makes the following claims which as far as I can see are entirely baseless, for the reasons given:
    A Java virtual machine is required to implement a preemptive, priority-based schedulerThe word 'pre-emptive' does not appear in the JLS.
    The Java virtual machine never changes the priority of a thread, even if the thread has been running for a certain period of timeCan't find that anywhere either.
    the contract between the Java virtual machine and the underlying operating system is that the operating system must generally choose to run the Java thread with the highest priorityThe 'contract' is between the Java code and the JVM, not the JVM and the O/S.
    That's what we mean when we say that Java implements a priority-based schedulerJava isn't required to 'implement' a scheduler at all.
    This scheduler is implemented in a preemptive fashion, meaning that when a higher-priority thread comes along, that thread interrupts (preempts) whatever lower-priority thread is running at the time.This appears nowhere in the JLS.
    The contract with the operating system, however, is not absolute, which means that the operating system can sometimes choose to run a lower-priority thread.In other words it's not pre-emptive. Make up your mind.
    Java's requirement for a priority-based, preemptive scheduling mechanism ...Which is nowhere to be found.
    A Java thread can have one of 11 prioritiesMIN_PRIORITY is 1, MAX_PRIORITY is 10: that makes 10, not 11.
    In fact, preemption means only that a higher-priority thread runs instead of a lower-priority oneNo it doesn't. It means that when a higher-priority thread becomes ready it pre-empts the execution of any lower-priority threads that are currently executing regardless of time-slice etc. This is a feature of real-time systems that Java is not required to implement.
    Summing up, the words 'pre-emptive' does not appear in the JLS, and the word 'scheduler' only appears in reference to sleep() and yield(), without any implication that the JVM has to implement one itself.

  • Thread scheduling problem in WLS5.1

    We use a Timer Servlet to schedule some back end tasks, however we found
              that from time to time the thread scheduling often get delayed or ahead in a
              outragous magtitude.
              We run the servlet inside WLS, and right after start up, the timer works
              perfect, but after long enough time (more than one day), the timer started
              to behave weird. It could get delayed for as much as hours, and then
              suddenly fired up all delayed tasks in a very short period of time. We then
              try to run a very simple Timer doing only wake up every 10 minutes and print
              one line, that failed too. We are running WLS5.1+sp3 on
              Solaris2.6(Generic_105181-19 sun4u sparc SUNW,Ultra-5_10) with jdk1.2.1_04.
              BTW, we found that it ran well on NT, at least for three days without
              problem.
              Any feedback will be appreciated!
              Qingxiang Ke
              below is the source for the simple timer, and deploy properties for it
              inside weblogic.properties file.
              SimpleTimerServlet.java
              package com.cysive.test;
              import java.io.*;
              import java.util.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class SimpleTimerServlet extends HttpServlet
              class Sleepy implements Runnable
              public void run()
              while(true)
              try
              long wakeUpTime = 600 * 1000;
              Thread.currentThread().sleep(wakeUpTime);
              System.out.println(new Date().toString() + " SimpleTimer Yawn
              ............ Yawn ............");
              catch(InterruptedException ie){}
              private static boolean timerIsRunning = false;
              public void init()
              if(! timerIsRunning)
              Thread sleepy = new Thread(new Sleepy());
              sleepy.start();
              timerIsRunning = true;
              public void doGet(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              doPost(request, response);
              public void doPost(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              OutputStream os = response.getOutputStream();
              os.write("look at your std out!!!".getBytes());
              os.flush();
              os.close();
              deploy properties in weblogic.properties
              weblogic.httpd.register.simpletimer=com.cysive.test.SimpleTimerServlet
              weblogic.system.startupClass.servletSimpleTimer=weblogic.servlet.utils.Servl
              etStartup
              weblogic.system.startupArgs.servletSimpleTimer=servlet=simpletimer
              

    We use a Timer Servlet to schedule some back end tasks, however we found
              that from time to time the thread scheduling often get delayed or ahead in a
              outragous magtitude.
              We run the servlet inside WLS, and right after start up, the timer works
              perfect, but after long enough time (more than one day), the timer started
              to behave weird. It could get delayed for as much as hours, and then
              suddenly fired up all delayed tasks in a very short period of time. We then
              try to run a very simple Timer doing only wake up every 10 minutes and print
              one line, that failed too. We are running WLS5.1+sp3 on
              Solaris2.6(Generic_105181-19 sun4u sparc SUNW,Ultra-5_10) with jdk1.2.1_04.
              BTW, we found that it ran well on NT, at least for three days without
              problem.
              Any feedback will be appreciated!
              Qingxiang Ke
              below is the source for the simple timer, and deploy properties for it
              inside weblogic.properties file.
              SimpleTimerServlet.java
              package com.cysive.test;
              import java.io.*;
              import java.util.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class SimpleTimerServlet extends HttpServlet
              class Sleepy implements Runnable
              public void run()
              while(true)
              try
              long wakeUpTime = 600 * 1000;
              Thread.currentThread().sleep(wakeUpTime);
              System.out.println(new Date().toString() + " SimpleTimer Yawn
              ............ Yawn ............");
              catch(InterruptedException ie){}
              private static boolean timerIsRunning = false;
              public void init()
              if(! timerIsRunning)
              Thread sleepy = new Thread(new Sleepy());
              sleepy.start();
              timerIsRunning = true;
              public void doGet(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              doPost(request, response);
              public void doPost(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              OutputStream os = response.getOutputStream();
              os.write("look at your std out!!!".getBytes());
              os.flush();
              os.close();
              deploy properties in weblogic.properties
              weblogic.httpd.register.simpletimer=com.cysive.test.SimpleTimerServlet
              weblogic.system.startupClass.servletSimpleTimer=weblogic.servlet.utils.Servl
              etStartup
              weblogic.system.startupArgs.servletSimpleTimer=servlet=simpletimer
              

  • Thread scheduling

    Hi, I have some questions bout threads.
    1) When it comes to thread scheduling, Java has no say in it, since thread scheduling is solely in a domain of operating system?
    2)In preemptive environment, when thread with higher priority becomes runnable, runtime will cause lower priority thread to halt and higher priority thread to start executing. This chosen thread will run until one of the following conditions is true:
    - a higher priority thread becomes "Runnable"
    - it yields, or its run() method exits
    - on systems that support time-slicing, its time has expired
    a) Time slicing doesn't mean that every thread will get the same amount of time to run?
    b)Will higher priority threads get more time and lower less!
    c) Does Windows OS support time slicing?
    3)What kind of environment is non-preemptive environment? The kind where threads with higher priority cant preempt lower priority threads? As I understand it, in those kind of environments there is a greater chance that some threads will never run. Why?
    4)Why is under non-preemptive environment greater chance of having situation where one of the two threads with same priority will not get a chance to run?
    bye

    beginprog wrote:
    1) When it comes to thread scheduling, Java has no say in it, since thread scheduling is solely in a domain of operating system?This is not strictly true. You can control when a thread is eligible to run, but you can't force a partiular thread to run. The JVM has some control over thread scheduling, but yes, it also interacts with the OS.
    2)In preemptive environment, when thread with higher priority becomes runnable, runtime will cause lower priority thread to halt and higher priority thread to start executing. This chosen thread will run until one of the following conditions is true:
    - a higher priority thread becomes "Runnable"
    - it yields, or its run() method exits
    - on systems that support time-slicing, its time has expired I don't think Java makes any such promises about its threads' priorities. You may be describing a general model, but in terms of the JVM scheduling its threads, higher priority threads will be preferred over lower priority ones, but the exact algorithm is left up to the implementation.
    a) Time slicing doesn't mean that every thread will get the same amount of time to run? There are many ways to implement time slicing. It depends on the VM implementation and the OS.
    b)Will higher priority threads get more time and lower less!Depends on the implementation.

  • Thread scheduling mechanism in SUN's VM

    I've the problem, that n threads share a resource
    (sharedObject).
    The synchronization is done in an synchronized
    Block:
    synchronized( sharedObject )
    // do something with sharedIbject
    I would like to know in which order the thread scheduler
    of SUN Solaris VM of the JDK 1.3 or in general,
    gives the lock of the sharedObject to one of the thread, which
    are waiting for the lock of the sharedObject.
    Is there something like FIFO, so that it's safe, that all waiting
    threads will get the sharedObject in the right order,
    or do i have to implement a queueing mechanism with wait and
    notify.
    thanks

    If you're writing a Java program that uses threads, the thing to do is to follow the rules that Java provides, not the rules of a particular thread scheduler.
    There is no guarantee about which order the threads will get access to the sharedObject without writing explicit code for it.

  • Thread Scheduling Query

    Hi,
    If i have 3 messages A, B and C which are in a queue and are to pass through a synchronized method Y . A particular thread X picks 1 message each from the queue and spawns a thread for each of 3.
    A is executing Y and B and C are in BLOCKING State and waiting for A to finish so that they can enter Y.
    Is it possible that C executes first before B.
    Pls advice.
    Thnx in Adv
    Amandeep

    Setting a thread's priority is not the preferred solution namely because it is dangerously inconsistent. The only time to use thread priority is when you have tasks that do not have scheduling conflicts like this and you really don't care when a particular thread runs. As an example the garbage collection thread in a VM is normally a lower priority thread until such time that garbage collection is needed.
    The preferred solution for thread scheduling and order of executing issues is to revisit the design.
    In the example given by the OP I would first question the use of multiple threads at all. It seems that the OP wished tasks to be executed from a queue in the same order as they were added to the queue and that tasks later in the queue should not finish execution before ones earlier.
    This does not seem a good use for multiple threads because this requirement seems to call for anything but parallel execution.
    But perhaps I am reading too much into that statement. I would suggest a revist of the design though to look at doing the following.
    Launcher thread
    1) Gets next thing from queue
    2) Calls synchonized Y method (that no longer needs to be synchronized probably) using thing from queue
    3) Starts new thread with results from Y
    4) Go back to 1
    This design garauantees at least that the launcher threads will be started (and past the synchronized method) in the same order as they were received.
    Does that mean they will complete execution in the same order? No. Does it mean they will actually start processing in the same order? No. But it does mean they will call Y in the same order and since I would guess that is the real issue here it solves the problem.
    If the threads really must finish in the same order than one must consider either; not running seperate threads as I mentioned earlier or adding a semaphore at the end of the spawned "worker" threads so that they wait for previous threads to finish before exiting.

  • Thread Scheduling Visualizer - take a look

    Hi,
    I want to share this link with all the sun forum members.
    It is about "The Sun Java Real-Time System Thread Scheduling Visualizer"
    [http://java.sun.com/javase/technologies/realtime/reference/TSV/JavaRTS-TSV.html]
    Sun you are simply too great ;)
    thanks,
    swapnaja
    Edited by: swapnaja on Mar 16, 2009 6:43 AM
    Edited by: swapnaja on Mar 16, 2009 6:48 AM

    Hi,
    Glad it worked for you too. I'm so grateful to 'turboontheovens' for posting this solution, it was driving me crazy!
    Claire x

  • Question about synchronize() statement and thread scheduling?

    I have threads accessing a shared LinkedList in the main thread. I made use of the Collections.synchronizedList() to avoid concurrent modifications. one of the threads is a timer thread and it has a priority of 5 and the other threads are message reception threads and i made them of a lower priority just to allow the timer thread to be executed on time. According to the javaAPI, all iterations on the synchronized list should be done using synchronized(synchronizedListRef){} and this is what i do,
    The problem is even after setting the priority of the reception threads lower than the timer thread, the reception threads are sometimes executed more than once and the timer thread is delayed. Lets assume the situation where the timer reaches the point where it has to acquire the lock (the synchronized statement) and it discovers that the lock is already taken and it cant access the list because the other thread (of a lower priority) is iterating over it. shouldnt the higherpriority thread be executed after that the reception thread (that is blocking the timer thread) finishes its execution and release the lock (even if there are other reception thread waiting)??
    does the priority play a role when a thread is blocked?

    Asady wrote:
    I have threads accessing a shared LinkedList in the main thread. I made use of the Collections.synchronizedList() to avoid concurrent modifications. Make sure you explicitly sync around all iterations. Just using Collections.sync is not enough.
    The problem is even after setting the priority of the reception threads lower than the timer thread, the reception threads are sometimes executed more than once and the timer thread is delayed.There's no guarantee as to how priority will be interpreted. The scheduler implementation is free to do pretty much anything.
    As for how to solve your problem, you might want to look at java.util.concurrent.*, e.g. PriorityQueue. If the classes there don't give you just what you need, you may be able to build on them, or at least get ideas from them. Bottom line is that if you want a specific scheduling algorithm, you'll have to implement it yourself, since Threads' priority semantics are only very loosely specified by the JLS.

  • How does Thread scheduling Work

    Hi to all out there. I have been deweloping a program that is supposed to create a Sceduling Thread that would have the higest priorety and manage three more threads. The sceduler creates a CircularList class to call and run each of the other three threads.
    Unfortunatly there are two errors that I can't trace down. If there is any one out there familiar with OS progming I would apreciate a few comments on the following code:
    import java.lang.*;
    public class TestScheduler
         public static void main (String args[])
              Thread.currentThread().setPriority(Thread.MAX_PRIORITY); //Sets Sceduler Priorety
              Scheduler CPUScheduler = new Scheduler();
              CPUScheduler.start();
    /*creates The three other threads to be managed*/
              Thread t1 = new TestThread();
              t1.start();
              //CPUScheduler.addThread(t1);
              Thread t2 = new TestThread();
              t2.start();
              Thread t3 = new TestThread();
              t3.start();
    class Scheduler extends Thread
         public Scheduler(){
              timeSlice = DEFAULT_TIME_SLICE;
    //creates the queues for threads
              queue = new CircularLi();
         public Scheduler(int quantum){
                   timeSlice = quantum;
                   queue = new CircularList();
         public void addThread(Thread t){
                   t.setPriority(2);
    //Error 1 here. Can't recognize the .addItem() method?
                   queue.addItem(t);
         private void schedulerSleep(){
                   try{
                        Thread.sleep(timeSlice);
                   }catch(InterruptedException e){};
         public void run(){
              Thread current;
              this.setPriority(6);
              while (true){
    //Error 2 is here. It sais it can't find a method .getNext()?
                   current = (Thread)queue.getNext();
                   if ((current != null) && (current.isAlive())){
                        current.setPriority(4);
                        schedulerSleep();
                        current.setPriority(2);
         private CircularList queue;
         private int DEFAULT_TIME_SLICE = 100;
         private int timeSlice;
    class TestThread extends Thread
         public void run()
              Total = 0;
              Total++;
              System.out.println("This ran for: " Total " times.");
         public int Total;
    class CircularList extends Scheduler
         public void run ()
              Thread.currentThread().setPriority(5);
              while(true)
                   if(Total < 5)
                        new TestThread().start();
                        Total++;
                   else
                        Thread.currentThread().setPriority(2);
                        Total = 0;
         private int Total = 0;
    Is there another library class I do not know about or do I have to write this methods myself?

    Where have you got the CircularList from?
    it is not part of the java API ... so who ever wrote it should be able to answer your question.
    If it sticks to the conventions of the collection API
    the method addItem is probably simply named add
    and instead of queque.next() you use an iterator instead like this:
    Iterator iter = queque.iterator();
    while (iter.hasNext()){
    Object o = iter.next();
    // do something with o
    HTH
    Spieler

  • Solaris 9 vs 10 wrt process/thread scheduling, from perspective of 'top'

    On a dual-processor UltraSpract Fire V240, running Solaris 9, the 'top' command shows:
    rodan%top
    load averages:  2.43,  2.23,  2.23                                 00:41:10
    39 processes:  35 sleeping, 2 running, 2 on cpu
    CPU states:     % idle,     % user,     % kernel,     % iowait,     % swap
    Memory: 2048M real, 1707M free, 160M swap in use, 2500M swap free
      PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
    1551 ssgolsha   1   0    0   62M   61M run   324:17 46.89% vpr
    1866 ssgolsha   1   0    0   22M   20M run    41:57 45.19% vpr
    1922 mingl      4   0    0   42M   39M cpu0    1:28  6.27% messengers
    1928 mingl      1  39    0 1640K 1208K cpu1    0:00  0.12% top-sun4u-5.7
      185 root       3  59    0 4920K 3352K sleep   0:14  0.02% automountd
    1583 mingl      1  49    0 3584K 3136K sleep   0:00  0.02% tcshrodan%top
    load averages:  2.77,  2.51,  2.35                                 00:41:45
    39 processes:  35 sleeping, 2 running, 2 on cpu
    CPU states:  0.0% idle, 99.8% user,  0.2% kernel,  0.0% iowait,  0.0% swap
    Memory: 2048M real, 1707M free, 160M swap in use, 2500M swap free
      PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
    1866 ssgolsha   1   0    0   22M   20M run    42:23 38.18% vpr
    1551 ssgolsha   1   0    0   62M   61M run   324:38 33.02% vpr
    1922 mingl      4   0    0   42M   39M cpu1    1:51 28.34% messengers
    1928 mingl      1  59    0 1640K 1280K cpu0    0:00  0.02% top-sun4u-5.7
      185 root       2  59    0 4920K 3352K sleep   0:15  0.00% automountd
      219 root      19  59    0 4760K 3552K sleep   0:03  0.00% nscd
    1583 mingl      1  59    0 3584K 3136K sleep   0:00  0.00% tcshSunOS 5.9's man page for 'top' says STATE is the current state (one of "sleep", "WAIT", "run", "idl", "zomb", or "stop")
    On a dual-processor dual-core AMD Opteron 270, running Solaris 10, the 'top' command shows:
    homer% top
    load averages:  0.11,  0.16,  0.12;                    up 7+08:19:46    17:11:47
    93 processes: 91 sleeping, 2 on cpu
    CPU states: 72.3% idle, 25.1% user,  2.5% kernel,  0.0% iowait,  0.0% swap
    Memory: 2048M phys mem, 1606M free mem, 8001M swap, 7873M free swap
       PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
    14685 mingl      4  30    0  112M  109M cpu      2:09   105% messengers
       258 root       1  59    0   13M 5260K sleep   74:52  0.70% Xorg
      9522 coby       1  59    0   47M 8116K sleep   22:44  0.33% mixer_applet2
      9520 coby       1  59    0   49M 8592K sleep    6:35  0.12% gnome-netstatus
       270 gdm        1  59    0   50M 6076K sleep    4:44  0.08% gdmgreeter
    14658 mingl      1  59    0 2068K 1488K cpu      0:00  0.08% top
    SunOS 5.10's man page for 'top' says
    STATE
    Current state (typically one of "sleep", "run", "idl", "zomb", or "stop").
    As seen in both cases, the 'messengers' program has 4 threads.
    On Solaris 9, its state is either cpu0 or cpu1, depending on the time I call 'top'. Does that mean it is actually running on either cpu0 or cpu1? What is the difference between the 'cpu0' state and the 'run'
    state? And does it mean all 4 threads are running/assigned to cpu0 (or cpu1)?
    On Solaris 10, the state shows 'cpu'. Does it mean it is running? And does it mean that each thread may run on a different CPU therefore the state does not show any particular CPU number? Is it correct that Solaris 9 assign the CPU on a per-process basis and Solaris 10 on a per-thread basis?

    On Solaris 9, its state is either cpu0 or cpu1,
    depending on the time I call 'top'. Does that mean
    it is actually running on either cpu0 or cpu1?Should be.
    What
    is the difference between the 'cpu0' state and the
    'run' state?A thread can be sleeping (it doesn't have anything to do), or runnable. Although it's runnable, it doesn't mean that it's running right at that instant.
    Note that it's difficult to get a good view of the situation with 'top' (or almost any other program). Because whenever 'top' looks, 'top' will always be running, even though it's only running a fraction of the time.
    And does it mean all 4 threads are
    running/assigned to cpu0 (or cpu1)? No. Each thread is independently executed. But since you only have 2 processors, and since 'top' has to be running when it runs, you'll only ever see your process on at most one other cpu.
    You might want to use 'prstat' and 'prstat -L'. The first shows one line per process, the second one line per thread.
    On Solaris 10, the state shows 'cpu'. Does it mean
    it is running? And does it mean that each thread may
    run on a different CPU therefore the state does not
    show any particular CPU number? Is it correct that
    Solaris 9 assign the CPU on a per-process basis and
    Solaris 10 on a per-thread basis?I don't know exactly what top does or doesn't do. You might try 'prstat' instead.
    There is no difference at this level between Solaris 9 and 10. All will schedule on a per-thread basis.
    Darren

  • Some kind of thread scheduling lag in 6.1sp2

    I've got a 2000sp4 box with Web Server 6.1sp2 installed. I'm running ColdFusion MX as well. The machine is a dual-P4 3.2Ghz. with 4gb of RAM.
    What I'm seeing is at random times, a user will request a page, and then be stuck waiting for a long time (think 10-30 seconds on average). Then, the next page request will load immediately.
    The connection queue is peaking at like 6 connections. It's not a connection queue issue. Iny my performance monitor, when these 'lag spikes' hit, as they come down, I see our ColdFusion process take on a spike in requests, as if during this 'lag spike' all the connections get stuck somewhere and, once cleared, they all go through at once.
    Both the ColdFusion and Sun One performance monitors show average request/response time at about 100ms.
    I've tested this on a dev machine and seen that the Sun One performance monitor does include CF processing time in the "Total Response Time" that gets reported.
    So since I'm only seeing about 150ms max for the "Total Response Time", that would seem to indicate my 'lag spike' is something that occurs at the point connections are accepted.
    The 'lag spikes' are not limited to requests for CF pages. Images, static files, and even the performance monitor are susceptible to these 'lag spikes'.
    One symptom that might be worth pointing out is that if I hit a 'lag spike' and simply stop my request, then re-request it (hit the reload button) the page will come up immediately.
    There are 8 virtual servers on the box, each has only 1 acceptor thread. I see these lag spikes on virtual servers that have nobody else but myself connecting to them, so I don't think it's an acceptor thread issue.
    KernelThreads is set to ON as setting it to OFF seems to make the web server virtually unresponsive.
    NativePool:
    Idle/Peak/Limit 1/1/64
    Work Queue Length/Peak/Limit 0/0/256
    I have never see the idle/peak values go above 1 for my NativePool. Is this "normal"? I do not have CF running in a separate thread pool.
    Does anyone have any ideas or suggestions?
    Thanks

    A couple of things.
    First, thanks for the tips. I was starting to suspect the network might be an issue (bad nic, bad router, something).
    But netstat -s was showing an average of about .15% packet loss. For a web server that seems to be a pretty good value so I'm not sure.
    I did, however, ask someone else to look at the server because I'd spent the whole week on just server performance and was going out of my mind. This second pair of eyes really helped as he found that the pagefile for the server was set at 2mb!? Still trying to figure out how that happened. But we increased the pagefile to a much better value. There wasn't an immediate change in performance, but over time the server appears to have begun to respond better.
    Occasionally I still get these 'lag spikes' but nowhere near what they were and the delay is much smaller as well, which is probably being caused by something else entirely (like bad programming on my part, hah).

  • Thread scheduling with Windows XP pro 64

    I am using JDK SE 5.0 update 7 with the eclipse IDE on Windows XP pro-64bit. Windows is a virtual machine running via VM-ware with Linux as the host OS.
    The basic function of my app is to recieve data from a socket via a listener (3rd party software). When data is available, it gets written to a list. (this is thread 1)
    My app has another thread (thread 2) of equal, default priority which tests the list for data. If there i data, it removes the oldest data and does some processing. (parse and print for example). My problem lies in that using this OS thread 2 seems to be using all the cpu and giving thread 1 little, if any cpu time. It seems like this OS isn't implementing timeslicing. I inserted a yield() in thread2 which helps, but the software still runs slow as a whole (I think thread2 is still hogging cpu).
    I have ran the same code on Win XP Pro -32 bit, as well as Linux without any yeilding or sleeping, and the program run super fast as if the timeslicing, round-robin is working great.
    My question is, does anyone know of any idiosynchracy of Windows XP pro-64 bit, or java that could be causing this? Any suggestions on how to fix it?
    Thanks,

    My app has another thread (thread 2) of equal, default priority which tests the list for data. If there i data,
    And if there's no data? I hope you don't do busy waiting, do you?
    (If so: Instead of busy waiting you shoud use a ArrayBlockingQueue or something like this.)

  • Installation of the Thread Scheduling Visualizer (TSV)

    Hi,
    I've already written some realtime applications and now I want to monitor them via TSV. I've downloaded RTS 2.1 with TSV and installed RTS 2.1. I guess TSV isn't installed yet (command "drecord" is not known by solaris). So I think TSV is inside the file "threadsc.gz", isn't it? I've already extracted this file, but still I don't know, how to install TSV.
    I've already read the TSV Guide, but there are only very poor informations on the installation of it.
    So can anyone explain to me, what the name of the TSV installation file is and how I can install it on Solaris?
    Thanks a lot!

    Hi Gordon:
    TSV can be downloaded when you download the Java RTS 2.1 eval on
    Solaris; just to be clear, TSV is based on DTrace (a Solaris specific
    tool), hence it's not available for Linux. When you go through the Java
    RTS 2,1 eval download process for Solaris (either x86 or SPARC version),
    you will see the TSV download link listed on the final page (after having
    taken the survey and agreeing with the eval license) -- it's the same
    page as the one that also lists the Java RTS 2.1 eval download link.
    The name of the TSV bundle on that page is "tsv-1.2.tar.gz". All you
    need to do to install this is to unpack it.
    HTH,
    -Carlos Lucasius
    http://sites.google.com/site/javartsandjavaseforembedded/

  • Can multiple threads write to the database?

    I am a little confused from the statement in the documentation: "Berkeley DB Data Store does not support locking, and hence does not guarantee correct behavior if more than one thread of control is updating the database at a time."
    1. Can multiple threads write to the "Simple Data Store"?
    2. Considering the sample code below which writes to the DB using 5 threads - is there a possibility of data loss?
    3. If the code will cause data loss, will adding DB_INIT_LOCK and/or DB_INIT_TXN in DBENV->open make any difference?
    #include "stdafx.h"
    #include <stdio.h>
    #include <windows.h>
    #include <db.h>
    static DB *db = NULL;
    static DB_ENV *dbEnv = NULL;
    DWORD WINAPI th_write(LPVOID lpParam)
    DBT key, data;
    char key_buff[32], data_buff[32];
    DWORD i;
    printf("thread(%s) - start\n", lpParam);
    for (i = 0; i < 200; ++i)
    memset(&key, 0, sizeof(key));
    memset(&data, 0, sizeof(data));
    sprintf(key_buff, "K:%s", lpParam);
    sprintf(data_buff, "D:%s:%8d", lpParam, i);
    key.data = key_buff;
    key.size = strlen(key_buff);
    data.data = data_buff;
    data.size = strlen(data_buff);
    db->put(db, NULL, &key, &data, 0);
    Sleep(5);
    printf("thread(%s) - End\n", lpParam);
    return 0;
    int main()
    db_env_create(&dbEnv, 0);
    dbEnv->open(dbEnv, NULL, DB_CREATE | DB_INIT_MPOOL | DB_THREAD, 0);
    db_create(&db, dbEnv, 0);
    db->open(db, NULL, "test.db", NULL, DB_BTREE, DB_CREATE, 0);
    CreateThread(NULL, 0, th_write, "A", 0, 0);
    CreateThread(NULL, 0, th_write, "B", 0, 0);
    CreateThread(NULL, 0, th_write, "B", 0, 0);
    CreateThread(NULL, 0, th_write, "C", 0, 0);
    th_write("C");
    Sleep(2000);
    }

    Here some clarification about BDB Lock and Multi threads behavior
    Question 1. Can multiple threads write to the "Simple Data Store"?
    Answer 1.
    Please Refer to http://docs.oracle.com/cd/E17076_02/html/programmer_reference/intro_products.html
    A Data Store (DS) set up
    (so not using an environment or using one, but without any of the DB_INIT_LOCK, DB_INIT_TXN, DB_INIT_LOG environment regions related flags specified
    each corresponding to the appropriate subsystem, locking, transaction, logging)
    will not guard against data corruption due to accessing the same database page and overwriting the same records, corrupting the internal structure of the database etc.
    (note that in the case of the Btree, Hash and Recno access methods we lock at the database page level, only for the Queue access method we lock at record level)
    So,
    if You want to have multiple threads in the application writing concurrently or in parallel to the same database You need to use locking (and properly handle any potential deadlocks),
    otherwise You risk corrupting the data itself or the database (its internal structure).
    Of course , If You serialize at the application level the access to the database, so that no more one threads writes to the database at a time, there will be no need for locking.
    But obviously this is likely not the behavior You want.
    Hence, You need to use either a CDS (Concurrent Data Store) or TDS (Transactional Data Store) set up.
    See the table comparing the various set ups, here: http://docs.oracle.com/cd/E17076_02/html/programmer_reference/intro_products.html
    Berkeley DB Data Store
    The Berkeley DB Data Store product is an embeddable, high-performance data store. This product supports multiple concurrent threads of control, including multiple processes and multiple threads of control within a process. However, Berkeley DB Data Store does not support locking, and hence does not guarantee correct behavior if more than one thread of control is updating the database at a time. The Berkeley DB Data Store is intended for use in read-only applications or applications which can guarantee no more than one thread of control updates the database at a time.
    Berkeley DB Concurrent Data Store
    The Berkeley DB Concurrent Data Store product adds multiple-reader, single writer capabilities to the Berkeley DB Data Store product. This product provides built-in concurrency and locking feature. Berkeley DB Concurrent Data Store is intended for applications that need support for concurrent updates to a database that is largely used for reading.
    Berkeley DB Transactional Data Store
    The Berkeley DB Transactional Data Store product adds support for transactions and database recovery. Berkeley DB Transactional Data Store is intended for applications that require industrial-strength database services, including excellent performance under high-concurrency workloads of read and write operations, the ability to commit or roll back multiple changes to the database at a single instant, and the guarantee that in the event of a catastrophic system or hardware failure, all committed database changes are preserved.
    So, clearly DS is not a solution for this case, where multiple threads need to write simultaneously to the database.
    CDS (Concurrent Data Store) provides locking features, but only for multiple-reader/single-writer scenarios. You use CDS when you specify the DB_INIT_CDB flag when opening the BDB environment: http://docs.oracle.com/cd/E17076_02/html/api_reference/C/envopen.html#envopen_DB_INIT_CDB
    TDS (Transactional Data Store) provides locking features, adds complete ACID support for transactions and offers recoverability guarantees. You use TDS when you specify the DB_INIT_TXN and DB_INIT_LOG flags when opening the environment. To have locking support, you would need to also specify the DB_INIT_LOCK flag.
    Now, since the requirement is to have multiple writers (multi-threaded writes to the database),
    then TDS would be the way to go (CDS is useful only in single-writer scenarios, when there are no needs for recoverability).
    To Summarize
    The best way to have an understanding of what set up is needed, it is to answer the following questions:
    - What is the data access scenario? Is it multiple writer threads? Will the writers access the database simultaneously?
    - Are recoverability/data durability, atomicity of operations and data isolation important for the application? http://docs.oracle.com/cd/E17076_02/html/programmer_reference/transapp_why.html
    If the answers are yes, then TDS should be used, and the environment should be opened like this:
    dbEnv->open(dbEnv, ENV_HOME, DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | DB_INIT_LOG | DB_RECOVER | DB_THREAD, 0);
    (where ENV_HOME is the filesystem directory where the BDB environment will be created)
    Question 2. Considering the sample code below which writes to the DB using 5 threads - is there a possibility of data loss?
    Answer 2.
    Definitely yes, You can see data loss and/or data corruption.
    You can check the behavior of your testcase in the following way
    1. Run your testcase
    2.After the program exits
    run db_verify to verify the database (db_verify -o test.db).
    You will likely see db_verify complaining, unless the thread scheduler on Windows weirdly starts each thread one after the other,
    IOW no two or ore threads write to the database at the same time -- kind of serializing the writes
    Question 3. If the code will cause data loss, will adding DB_INIT_LOCK and/or DB_INIT_TXN in DBENV->open make any difference?
    Answer 3.
    In Your case the TDS should be used, and the environment should be opened like this:
    dbEnv->open(dbEnv, ENV_HOME, DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | DB_INIT_LOG | DB_RECOVER | DB_THREAD, 0);
    (where ENV_HOME is the filesystem directory where the BDB environment will be created)
    doing this You have proper deadlock handling in place and proper transaction usage
    so
    You are protected against potential data corruption/data loss.
    see http://docs.oracle.com/cd/E17076_02/html/gsg_txn/C/BerkeleyDB-Core-C-Txn.pdf
    Multi-threaded and Multi-process Applications
    DB is designed to support multi-threaded and multi-process applications, but their usage
    means you must pay careful attention to issues of concurrency. Transactions help your
    application's concurrency by providing various levels of isolation for your threads of control. In
    addition, DB provides mechanisms that allow you to detect and respond to deadlocks.
    Isolation means that database modifications made by one transaction will not normally be
    seen by readers from another transaction until the first commits its changes. Different threads
    use different transaction handles, so this mechanism is normally used to provide isolation
    between database operations performed by different threads.
    Note that DB supports different isolation levels. For example, you can configure your
    application to see uncommitted reads, which means that one transaction can see data that
    has been modified but not yet committed by another transaction. Doing this might mean
    your transaction reads data "dirtied" by another transaction, but which subsequently might
    change before that other transaction commits its changes. On the other hand, lowering your
    isolation requirements means that your application can experience improved throughput due
    to reduced lock contention.
    For more information on concurrency, on managing isolation levels, and on deadlock
    detection, see Concurrency (page 32).

  • Scheduling a report in background and passing data for processing

    Hi all,
    Using code (in a report1) ...i  want to execute a report (report2) in background.....but at the same time i want to pass data (an internal table and a variable) to that report2.
    is it possible to pass data like internal table to a executable report and at the same time pass the data to that report.
    Thanks in advance.
    Thanks and Regards,
    Sushil.

    hi
    regarding  Scheduling a report in background check the below thread
    SCHEDULE THE ZREPORT IN BACKGROUND DYNAMICALLY
    regards
    chandra

Maybe you are looking for

  • BOM Uploading through LSMW

    Hi Experts,   I am Uploading BOM through LSMW by Direct Input method. I am having the following queries,   1.  In that BOM I have Header data and Item data. While doing the Step 7(specify file) it accept the text file only not the Excel file. If I as

  • Discoverer 3.1.36.06 Turkish character problem

    Hi, I am trying to get reports using Discoverer 3.1.36.06. Though my database is Turkish and I can select accurate Turkish characters from it using TOAD or reporting tools like Business Objects, there occurs a problem when using Discoverer to produce

  • Free Drum Loops for you to play with

    Hey all: In the holiday spirit of giving back to the community, etc., etc., I thought maybe you all would enjoy some badass drum loops to play around with in Soundtrack Pro (my all-time favorite Apple program). So here goes: This is a zip file contai

  • Auto submit trigger required validation

    I am using Jdeveloper 11g R (11.1.2.3) & weblogic 10 G In my pages I use JSF & Facelet In a page I have a field with Auto submit = true and another field with required = true When I a create a new record and add some thing in first field second field

  • SCEP for Yosemite

    Hi, Can someone please tell how to obtain SCEP for OS X Yosemite. I can't seem to find it. Please be detailed in your reply. Thanks.