Subversion Repositories freemyipod

Rev

Rev 389 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 389 Rev 392
Line 491... Line 491...
491
        """
491
        """
492
            Fetches data on the currently running processes
492
            Fetches data on the currently running processes
493
        """
493
        """
494
        import datetime
494
        import datetime
495
        threads = self.embios.getprocinfo()
495
        threads = self.embios.getprocinfo()
496
        cpuload = 1
-
 
497
        threadload = 0
496
        threadload = 0
498
        idleload = 0
497
        idleload = 0
499
        for thread in threads:
498
        for thread in threads:
500
            if thread.priority != 0:
499
            if thread.id != 0:
501
                threadload += (thread.cpuload*100)/255
500
                threadload += thread.cpuload / 255.
502
            else:
501
            else:
503
                idleload += (thread.cpuload*100)/255
502
                idleload += thread.cpuload / 255.
504
        coreload = 1 - (threadload + idleload)
503
        coreload = 1 - (threadload + idleload)
505
        cpuload = threadload + coreload
504
        cpuload = threadload + coreload
506
        self.logger.info("The device has " + str(len(threads)) + " running threads.\n" + \
505
        self.logger.info("Threads: %d, CPU load: %.1f%%, kernel load: %.1f%%, user load: %.1f%%\n\n"
507
                         "It is running at " + str(cpuload * 100) + "% cpu load with a kernel load of " + \
506
                         % (len(threads), cpuload * 100, coreload * 100, threadload * 100))
508
                         str(coreload * 100) + "% and a user load of " + str(threadload * 100) + "%\n\n")
-
 
509
        self.logger.info("Thread dump:\n")
507
        self.logger.info("Thread dump:\n")
510
        for thread in threads:
508
        for thread in threads:
511
            self.logger.info("  "+thread.name+":\n")
509
            self.logger.info("  "+thread.name+":\n")
512
            self.logger.info("    Thread id: "      + str(thread.id)+"\n")
510
            self.logger.info("    Thread id: "      + str(thread.id)+"\n")
513
            self.logger.info("    Thread type: "    + thread.type+"\n")
511
            self.logger.info("    Thread type: "    + thread.type+"\n")
514
            self.logger.info("    Thread state: "   + thread.state+"\n")
512
            self.logger.info("    Thread state: "   + thread.state+"\n")
515
            self.logger.info("    Block type: "     + thread.block_type+"\n")
513
            self.logger.info("    Block type: "     + thread.block_type+"\n")
516
            self.logger.info("    Blocked by: "     + self._hex(thread.blocked_by_ptr)+"\n")
514
            self.logger.info("    Blocked by: "     + self._hex(thread.blocked_by_ptr)+"\n")
517
            self.logger.info("    Priority: "       + str(thread.priority)+"/255\n")
515
            self.logger.info("    Priority: "       + str(thread.priority)+"/255\n")
518
            self.logger.info("    Current CPU load: "+str((thread.cpuload*100)/255)+"%\n")
516
            self.logger.info("    Current CPU load: %.1f%%\n" % ((thread.cpuload * 100) / 255.))
519
            self.logger.info("    CPU time (total): "+str(datetime.timedelta(microseconds=thread.cputime_total))+"\n")
517
            self.logger.info("    CPU time (total): "+str(datetime.timedelta(microseconds = thread.cputime_total))+"\n")
520
            self.logger.info("    Stack address: "  + self._hex(thread.stackaddr)+"\n")
518
            self.logger.info("    Stack address: "  + self._hex(thread.stackaddr)+"\n")
521
            self.logger.info("    Registers:\n")
519
            self.logger.info("    Registers:\n")
522
            for registerrange in range(4):
520
            for registerrange in range(4):
523
                self.logger.info("      ")
521
                self.logger.info("      ")
524
                for register in range(registerrange, 16, 4):
522
                for register in range(registerrange, 16, 4):