星期二, 12月 21, 2021

recvmsg和sendmsg函数

 

recvmsg和sendmsg函数

SCM_RIGHTS
https://blog.csdn.net/u014209688/article/details/71311973
http://blog.chinaunix.net/uid-20937170-id-4247670.html

AF_INET域与AF_UNIX域socket通信原理对比

 

AF_INET域与AF_UNIX域socket通信原理对比

https://blog.csdn.net/sandware/article/details/40923491

星期四, 7月 01, 2021

Load average

 Load average 

https://zhuanlan.zhihu.com/p/75975041 

Linux Load Averages:什么是平均负载?

https://link.zhihu.com/?target=http%3A//www.brendangregg.com/blog/2017-08-08/linux-load-averages.html

星期二, 3月 23, 2021

time zone

  1. timedatectl set-timezone "Asia/Taipei"
  2.  tzdate  (text GUI)

ESP 32 dev

 


Install ESP-IDF v4.2

https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s2/get-started/windows-setup.html


Air Kiss Related:

  1. Air Kiss技术实现方案(0.5)
  2. WeChatAirKiss Android客户端
  3. AirKissDemo
    1. 声明: 目前AirKiss协议已经发展到3.0版本(详见微信硬件平台),此版本应该还是基于最初的设计实现,仅供学习研究使用,不建议作为商业产品

FauxmoESP:

星期五, 3月 19, 2021

SARA-R4

 

Term:

  1. mmcli 
  2. ModemManager
  3. NetworkManager
  4. SARA-R4

Reference:

  1. https://techship.com/faq/how-to-guide-control-and-set-up-a-data-connection-in-linux-using-modemmanager-as-connection-manager/
  2. https://askubuntu.com/questions/1118595/how-to-establish-ip-connection-for-wwan-on-18-04


星期五, 3月 12, 2021

MP4 muxing

 


Muxing

 

  1. https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/muxing.c
  2. lieff/minimp4

 


Demuxing

https://github.com/Akaaba/libmp4


ISO 14496-1 Media Format

https://xhelmboyx.tripod.com/formats/mp4-layout.txt

星期五, 1月 29, 2021

星期三, 1月 27, 2021

fs_may_remount_ro

 fs_may_remount_ro

[  159.383252] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[  159.383258] FAT-fs (sdb1): Filesystem has been set read-only

ICE/Stun/Turn/signaling/coturn/webrtc

 



ICE/Tune server test tool

  1. https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

https://medium.com/@omidborjian/setup-your-own-turn-stun-signal-relay-server-on-aws-ec2-78a8bfcb71c3





星期三, 1月 20, 2021

星期二, 1月 19, 2021

thread's signal mask

 thread's signal mask

copy from:

https://jyhshin.pixnet.net/blog/post/27826709


就跟傳統的 process 一樣,每個 thread 都有一個 signal mask,用來指定那些非同步 signal 會被 thread 處理,稱為 unblocked signals,那些 signal 不會被 thread 處理,稱為 blocked signals。根據 kernel 的設計,child process 中的第一個 thread 會繼承 parent process 中呼叫 fork 的 thread 的 signal mask,其它 thread 則會繼承呼叫 pthread_create 的 thread 的 signal mask。然後在 thread 再利用 pthread_sigmask 來調整 signal 是 blocked or unblocked。

當一個非同步產生的 signal 送達某個 process 時,它將由 process 中某個 thread 來處理,系統將會根據每個 thread 的 signal mask 來決定誰是選中的 thread 。如果有超過一個以上的 thread,它們的 signal mask 對 signal 來說都是 unblocked,系統將任意的幫你選一個。雖然你可以經由設定 signal mask 來影響系統選 thread 的過程,但無法直接指定某個 thread 來處理某個指定的 signal。

下面演示 pthread_sigmask 的範例,每隔二秒發出 SIGALRM 一次,由這個範例得到幾個結論。

  1. 預設的 signal mask = 0,也就是所有的 signal 都是 unblocked。
  2. signal 對 threads 的選擇都是以 thread 產生的順序為則準,所以每次都是第一個 threads 被選中。
  3. main 算是第一個 thread,如果沒有在 main 中使用 pthread_sigmask 來 block signal,則所有的 signal 都會由 main thread 來處理。
  4. main 中使用 pthread_sigmask 要注意,如果在 pthread_create 前使用,後面的 threads 會繼承變更後的 signal mask。
#include <pthread.h> #include <stdio.h> #include <time.h> #include <sys/signal.h> #include <sys/time.h> #define NUMTHREADS 3 void *thread_normal(void *parm) { pthread_t tid = pthread_self(); int rc; printf("Thread %u entered\n", tid); rc = sleep(15); if (rc != 0) { printf("Normal thread %u did not get expected results! rc=%d\n", tid, rc); pthread_exit(NULL); } printf("Normal thread %lu completed masked work\n", tid); pthread_exit(NULL); } void *thread_masked(void *parm) { pthread_t tid = pthread_self(); sigset_t mask; int rc; printf("Masked thread %lu entered\n", tid); sigfillset(&mask); rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); if (rc != 0) { printf("%d, %s\n", rc, strerror(rc)); return NULL; } rc = sleep(15); if (rc != 0) { printf("Masked thread %lu did not get expected results! rc=%d \n", tid, rc); pthread_exit(NULL); } printf("Masked thread %lu completed masked work\n", tid); pthread_exit(NULL); } void sighand(int signo) { pthread_t tid = pthread_self(); printf("Thread %lu in signal handler, time=%d\n", tid, time(NULL)); return; } int main(int argc, char **argv) { int i, rc; sigset_t mask; struct itimerval itv; struct sigaction actions; pthread_t threads[NUMTHREADS]; pthread_t maskedthreads[NUMTHREADS]; printf("Enter Testcase - %s\n", argv[0]); printf("Set up the alarm handler for the process\n"); memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = sighand; rc = sigaction(SIGALRM,&actions,NULL); printf("Create masked and unmasked threads\n"); for(i=0; i<NUMTHREADS; ++i) { rc = pthread_create(&threads[i], NULL, thread_normal, NULL); if (rc != 0) { printf("%d, %s\n", rc, strerror(rc)); return -1; } rc = pthread_create(&maskedthreads[i], NULL, thread_masked, NULL); if (rc != 0) { printf("%d, %s\n", rc, strerror(rc)); return -1; } } sigfillset(&mask); /* Mask all allowed signals */ rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); if (rc != 0) { printf("%d, %s\n", rc, strerror(rc)); return -1; } printf("start time = %ld\n", time(NULL)); itv.it_interval.tv_sec = 2; itv.it_interval.tv_usec = 0; itv.it_value = itv.it_interval; setitimer(ITIMER_REAL, &itv, NULL); printf("Wait for masked and unmasked threads to complete\n"); for(i=0; i<NUMTHREADS; ++i) { rc = pthread_join(threads[i], NULL); rc = pthread_join(maskedthreads[i], NULL); } printf("Main completed\n"); return 0; }

執行結果

Enter Testcase - ./a.out Set up the alarm handler for the process Create masked and unmasked threads Thread 1082322112 entered Masked thread 1090710592 entered Thread 1099099072 entered Masked thread 1116941120 entered Thread 1125329600 entered Masked thread 1133718080 entered start time = 1242631196 Wait for masked and unmasked threads to complete Thread 1082322112 in signal handler, time=1242631198 Normal thread 1082322112 did not get expected results! rc=13 Thread 1099099072 in signal handler, time=1242631200 Normal thread 1099099072 did not get expected results! rc=11 Thread 1125329600 in signal handler, time=1242631202 Normal thread 1125329600 did not get expected results! rc=9 Masked thread 1090710592 completed masked work Masked thread 1116941120 completed masked work Masked thread 1133718080 completed masked work Main completed