Wednesday, May 9, 2018

Integer Constants in C language


https://download.mikroe.com/documents/compilers/mikroc/pic32/help/integer_constants.htm

Monday, May 7, 2018

upgrade firefox on ubuntu

solution 1.

sudo add-apt-repository ppa:ubuntu-mozilla-security/ppa
(sudo add-apt-repository ppa:mozillateam/firefox-next ??)

sudo apt-get update

sudo apt-get install firefox

solution 2.

Download firefox.tar.gz2
www.mozilla.com/firefox/

Extract it
tar xvjf firefox-59.0.tar.bz2


Move to /opt
Remove previous one if you have
sudo rm -rf /opt/firefox

Move the downloaded firefox directory to /opt
sudo mv firefox /opt/firefox_xx


Set up symbolic links
sudo mv /usr/bin/firefox /usr/bin/firefox-old
sudo ln -s /opt/firefox_xx/firefox /usr/bin/firefox

bash loop

run.sh
#!/bin/sh
for ((c = 1; c < 1000; c++))
do
echo "running $c times"
/root/en.sh
sleep 60
/root/run_ping.sh
done

root@LCDV2-00084:/root# cat run_ping.sh
#!/bin/sh
ping -c 5 192.168.1.121

Thursday, May 3, 2018

linux kernel tracer docs


https://www.kernel.org/doc/Documentation/trace/ftrace.txt

jiffies / time in linux kernel


https://cyberglory.wordpress.com/2011/08/21/jiffies-in-linux-kernel/

* jiffies will not be increased if timer interruption is disabled

#include <linux/time.h>

static s64 get_ns(void)
{
struct timespec ts;
getnstimeofday(&ts);
return timespec_to_ns(&ts);
}

unsigned long before, after;
unsigned int interval;

before = jiffies;
poll_wait(file, &runtime->sleep, wait);
after = jiffies;

interval = jiffies_to_usecs(after - before);

################################################

#include <linux/rtc.h>

struct timeval time;
unsigned long local_time;
 struct rtc_time tm_val;

do_gettimeofday(&time);
local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
rtc_time_to_tm(local_time, &tm_val);

printk(" @ (%04d-%02d-%02d %02d:%02d:%02d)\n", tm_val.tm_year + 1900, tm_val.tm_mon + 1,       tm_val.tm_mday, tm_val.tm_hour, tm_val.tm_min, tm_val.tm_sec);

################################################

struct timeval now;
struct tm tm_val;

do_gettimeofday(&now);
time_to_tm(now.tv_sec, 0, &tm_val);
printk(KERN_INFO "%d/%d %02d:%02d:%02d Days since 1 Jan: %d\n", tm_val.tm_mon + 1,
    1900 + tm_val.tm_year, tm_val.tm_hour, tm_val.tm_min,
    tm_val.tm_sec, tm_val.tm_yday);