Have a look at "nice" import os os.nice(-20)
A nice value of -20 represents highest priority, and a nice value of 19 represent least priority for a process. On Mon, Feb 22, 2016 at 5:01 PM, Upol Ryskulova <[email protected]> wrote: > How can I give higher priority to user-space signal which emits data by usig > PySide Signal class over the interrupt which reads value from a sensor when > edge is rising of beaglebone black(BBB) gpio. The sensor rate is set to 860, > so in every second it reads 860 data, consequently changes the flow of the > process 860 times, and when 860 data has been read from the sensor it takes > average of that values and emits PySide Signal with data (we should not > return values from interrupt handler function and they have to have really > short execution time period, that is why I used Pyside's Signal class to > emit signal with data). This signal emitted is connected to printWeight() > data in the server-side, and expected to execute when signal is emitted. But > since interrupt is generated 860 times per second cpu usage is not given to > server-side. How can I handle this issue? my server.py is as follows > > from bottle import > redirect,get,post,request,response,template,run,route,Bottle,static_file > from bottle.ext.websocket import GeventWebSocketServer > from bottle.ext.websocket import websocket > import time > import signal > > from HardwareInterrupt import Hardware > from Signals import _Signal_DataArrived > import signal > > hardware = None > def printWeight(data): > global hardware > print "data = ",data > > #signal.signal(signal.SIGALRM,printWeight) > > @route('/') > def websocket(): > global hardware > hardware = Hardware() > hardware.setups() > #hardware.startReadingValue() > print "hardware..." > > > _Signal_DataArrived.run(printWeight) > run(host='0.0.0.0',port=8001,server=GeventWebSocketServer) > > and HardwareInterrupt.py is like this > > ...... > def setups(self): > #setting Gpio setups > Gpio.setup("P9_24", Gpio.IN,pull_up_down=Gpio.PUD_DOWN) > Gpio.add_event_detect("P9_24", Gpio.RISING) > self.setupI2cSettings() > > Gpio.add_event_callback(_SensorValueDetectedPin,self.readValueFromSensor) > > > def readValueFromSensor(self,channel): > if (self.count == 860): > result=self.total/self.count > weight = result * self.sensorValueToGramConverter > weight = > self.doCalibration(weight,self.prev_weight)#currentVal)#,previousVal) > self.prev_weight = weight > print '%.2f' % (weight) > self.count = 0 > result = 0 > self.total = 0 > obj = {'weight':weight} > self._weight = weight > _Signal_DataArrived.emitIt(weight) > import time > time.sleep(0.1) > self.count = self.count + 1 > MSB, LSB = self.i2c.readList(0x00, 2) > combined = (MSB << 8) | LSB # gelen verinin decimal hali > self.total +=combined > .... > > > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
