Error: Virtualbox guest additions: modprobe vboxsf failed


shared folder Error: Virtualbox guest additions: modprobe vboxsf failed

$ sudo apt-get install virtualbox-guest-dkms
$ sudo apt-get install linux-headers-virtual


#Example #Error #Virtualbox #linux

linux "ps" command example


"ps" command example
: If i use "ps" command, I can check working process.

$ ps [-option]
-a : enumerates all processes (total user)
-u : each process of user and usage time
-x: enumerates all processes without a controlling terminal
-l : enumerates the detailed information
-e: Display all processes statuses

Example)
 ps -aux


PID : process id
%CPU : cpu usage
%MEM : memory usage
VSZ : virtual memory usage
RSS : real memory usage
Stat : process status ( S : sleep, I : idle, T : stop, …)

Linux : search content (in file) / and search file or folder example


search content
$ grep -r "content" ./*
  ex) grep -r "LD_PRELOAD" ./*

search file or folder
$ find ./* -name "file or folder"
  ex) find ./* -name "library" or find ./* -name "*lib*"

android pdk make error : Android can only be built by versions 3.81 and 3.82.


This error is caused by an incorrect "make" version.

root@kiwon-VirtualBox:~/pdk/android-4.4.2_r1# make
build/core/main.mk:45: ********************************************************************************
build/core/main.mk:46: *  You are using version 4.1 of make.
build/core/main.mk:47: *  Android can only be built by versions 3.81 and 3.82.
build/core/main.mk:48: *  see https://source.android.com/source/download.html
build/core/main.mk:49: ********************************************************************************
build/core/main.mk:50: *** stopping.  Stop.

This error is caused by an incorrect "make" version.
So, Please add "make" version.

$make -v
GNU Make 4.1
.…

Please add "make" version 4.1 .
$ vi ./build/core/main.mk

 40 # Check for broken versions of make.


 41 # (Allow any version under Cygwin since we don't actually build the platform there.)

 42 ifeq (,$(findstring CYGWIN,$(shell uname -sm)))

 43 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.81))

 44 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.82))

 45 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 4.1))

 46 $(warning ********************************************************************************)

 47 $(warning *  You are using version $(MAKE_VERSION) of make.)

 48 $(warning *  Android can only be built by versions 3.81 and 3.82.)

 49 $(warning *  see https://source.android.com/source/download.html)

 50 $(warning ********************************************************************************)

 51 $(error stopping)

 52 endif

 53 endif

 54 endif

 55 endif



Okay .

QT set background image example(QLable_setstylesheet, QPixmap)

QT set background image example(QLable_setstylesheet, QPixmap)
I had a problem about applying image.

This is problem :
My app is working on an embedded system. I have migrated the app from Qt 5.6 to Qt 5.9.3 and it became very slow. I have checked the output of the top command and realized that my app is causing a CPU utilization of 100%.
So, I have check my app and I have found a problem in this part of the code:
MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
{
...

    QPixmap bg(BACK_IMG_PATH);
    bg.fill(Qt::transparent);
    QPalette p(palette());
    p.setBrush(QPalette::Background, bg);
    setAutoFillBackground(true);
    setPalette(p);
...
}
The problem is, that if I add the code for the background, my app becomes extremely slow. However, if I remove this code, my app is working as expected. This cannot be a solution though, cause I need the background.
This problem did not exist before the migration.
I have tried to solve this by reimplementing the paintEvent and using QPainter like this:
void MainWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.drawImage(QRectF(this->x(), this->y(), this->width(), this->height()), QImage("img/bg_1280_720.png"));
}
This result is slightly faster, but still not satisfactory (the cpu utilization is 50%).


How to solve this problem?

before:
#define BACK_IMG_PATH           "/img/bg_1280_720.png"
    QPixmap bg(BACK_IMG_PATH);
    bg.fill(Qt::transparent);
    QPalette p(palette());
    p.setBrush(QPalette::Background, bg);
    setAutoFillBackground(true);
    setPalette(p);


after:

#define BACK_IMG_PATH           "background-image:url(/img/bg_1280_720.png)"
    QLabel *labelBg = new QLabel(this);
    labelBg->setStyleSheet(BACK_IMG_PATH);
    labelBg->setGeometry(this->geometry());


Java Lotto / get random number example

This code was made in five minutes, so there are many weak point.

this code save that the number from 1 to 45 has been count N times.
finally, i will get 6 numbers.

import java.util.Random;

public class lottonamatja {
   public static void main(String[] args) {
      Random ranNum = new Random();    // random variable
      long[] cloneNum = new long[45]; 
      long[] num = new long[45];
      long[] lottoNum = new long[6];    // get real number(I wanted)
      long count = 1;
      long N = 100000000;
   
      for (long i = 0; i< N ; i++) {
         int tempRanNum = ranNum.nextInt(45)+1;    // random number of 1~45
         num[tempRanNum-1] += count;    // count of each number about N times
      }

//copy number
      cloneNum = num.clone();

// sorting count
      for (int i = 0; i < 45; i++) {
         for (int j = i + 1; j < 45; j++) {
            if (num[i] > num[j]) {
               long tmp = 0;
               tmp = num[i];
               num[i] = num[j];
               num[j] = tmp;
            }
         }
      }
   
// compare sorting number to original number ( this is real number(1~45), num[i] or cloneNum[j] is counting number)
      for (int i = 0 ; i < 6; i++) {
         for (int j = 0 ; j < 45; j++) {
            if (num[i] == cloneNum[j])
               lottoNum[i] = j+1;    // save result number 
         }
      }
   
// sorting about 6 number
      for (int i = 0; i < 6; i++) {
         for (int j = i + 1; j < 6; j++) {
            if (lottoNum[i] > lottoNum[j]) {
               long tmp = 0;
               tmp = lottoNum[i];
               lottoNum[i] = lottoNum[j];
               lottoNum[j] = tmp;
            }
         }
         System.out.print(lottoNum[i] + " ");    //i wanted to real number
      }
   }
}

RSS(Resident Set Size), VSS(Virtual Set Size)


RSS(Resident Set Size): Number of physical pages associated with the process(the size is calculated with duplicated shared memoy size, so, is calculated lager than the actual size)

VSS(Virtual Set Size): Size of virtual memory associated with the process


But, the amount of memory about the process is unknown exactly.


Why is the CPU utilization(%) for each process greater than the total CPU Time about "top"?


Why is the CPU utilization(%) for each process greater than the total CPU Time about "top"?

Two modes of "top" : solaris(irix mode off), irix(irix mode on)

Solaris mode: total cpu utilization(%) / total cpu count(number of core)
Irix mode: each cpu utilization(%) * total cpu count(number of core)

SMP(symmetric multiprocessing)

SMP(symmetric multiprocessing, 대칭형 다중 처리)

대칭형 다중 처리(symmetric multiprocessing, SMP)는 두 개 또는 그 이상의 프로세서가 한 개의 공유된 메모리를 사용하는 다중 프로세서 컴퓨터 아키텍처이다. 현재 사용되는 대부분의 다중 프로세서 시스템은 SMP 아키텍처를 따르고 있다.

SMP 시스템은, 작업을 위한 데이터가 메모리의 어느 위치에 있는지 상관없이 작업할 수 있도록 프로세서에게 허용한다. 운영체제의 지원이 있다면, SMP 시스템은 부하의 효율적 분배를 위해 프로세서간 작업 스케줄링을 쉽게 조절할 수 있다. 그러나 메모리는 프로세서보다 느리다. 단일 프로세서라도 메모리로부터 읽는 작업에 상당한 시간을 소비한다. SMP는 이를 더욱 악화시키는데, 한 번에 한 개의 프로세서만이 동일한 메모리에 접근 가능하기 때문이다. 이는 다른 프로세서들을 대기하도록 만든다.

SMP는 운영체제와 메모리를 공유하는 여러 프로세서가 프로그램을 수행하는 것을 말한다. SMP에서는 프로세서가 메모리와 입출력 버스 및 데이터 경로를 공유하며, 또한 하나의 운영체제가 모든 프로세서를 관리한다. 보통 2개부터 32개의 프로세서로 이루어지며, 어떤 시스템은 64개까지 프로세서를 공유한다. SMP 시스템은 보통 MPP 시스템에 비하여 병렬 프로그래밍이 훨씬 쉽고, 프로세서간 작업 분산(workload balance)을 시키기가 훨씬 용이하지만, 확장성은 MPP에 비하여 취약하다. 또한 많은 사용자가 동시에 데이터베이스에 접근하여 일을 처리하는 OLTP 작업에서도 강점을 보인다.

출처: https://ko.wikipedia.org/wiki/%EB%8C%80%EC%B9%AD%ED%98%95_%EB%8B%A4%EC%A4%91_%EC%B2%98%EB%A6%AC


Symmetric multiprocessing (SMP) involves a multiprocessor computer hardware and software architecture where two or more identical processors are connected to a single, shared main memory, have full access to all input and output devices, and are controlled by a single operating system instance that treats all processors equally, reserving none for special purposes. Most multiprocessor systems today use an SMP architecture. In the case of multi-core processors, the SMP architecture applies to the cores, treating them as separate processors.

Professor John D. Kubiatowicz considers traditionally SMP systems to contain processors without caches.[1] Culler and Pal-Singh in their 1998 book "Parallel Computer Architecture: A Hardware/Software Approach" mention: "The term SMP is widely used but causes a bit of confusion. [...] The more precise description of what is intended by SMP is a shared memory multiprocessor where the cost of accessing a memory location is the same for all processors; that is, it has uniform access costs when the access actually is to memory. If the location is cached, the access will be faster. but cache access times and memory access times are the same on all processors."[2]

SMP systems are tightly coupled multiprocessor systems with a pool of homogeneous processors running independently of each other. Each processor, executing different programs and working on different sets of data, has the capability of sharing common resources (memory, I/O device, interrupt system and so on) that are connected using a system bus or a crossbar.

출처: https://en.wikipedia.org/wiki/Symmetric_multiprocessing

linux reboot f option (forced reboot)


Reboot  option
"-f" option ( $ reboot -f )
It is unsafe and does not recommend.
The system will be forced shutdown.(like turning off the power button)

unsafe / not recommend
The process is power off without performing a normal shutdown.
If the critical processing is done in the shutdown process, it can cause problems in the system.

Watchdog decription

Watchdog ?

The Linux kernel can reset the system if serious problems are detected. This can be implemented via special watchdog hardware, or via a slightly less reliable software-only watchdog inside the kernel. Either way, there needs to be a daemon that tells the kernel the system is working fine. If the daemon stops doing that, the system is reset.

watchdog is such a daemon. It opens /dev/watchdog, and keeps writing to it often enough to keep the kernel from resetting, at least once per minute. Each write delays the reboot time another minute. After a minute of inactivity the watchdog hardware will cause the reset. In the case of the software watchdog the ability to reboot will depend on the state of the machines and interrupts.


Thanks for reference.

reference : https://www.systutorials.com/docs/linux/man/8-watchdog/

how to install RPM file (Linux)

how to install RPM file (Linux)

Option
-i : use to install new package  (--install)
-U : update new version package(exist old version package),
      and if not exist old package, install new package (same option: -i)
-F :  fresh option, if you have a previous version installed, install.(--freshen)
-v : detailed message
--force : forced installation
--nodeps : ignore dependency and install
-vv : show detailed message during installation
--oldpackage : down grade

recommend option:
-ivh : install new package
-Uvh : update or install new package
-Fvh : if exist old package, only use this option(but, -Uvh use more than)



example:
// make temp dir 
$ mkdir ~/test
// copy rpm file
$ cp /path/name.rpm ~/test
$ cd ~/test
// install rpm

$ rpm -Uvh --force --nodeps name.rpm

QT QDBusMessage, QDBusReply example

QDBusMessage

QDBusMessage msg = QDBusMessage::createMethodCall("ServiceName", "PathName", "InterfaceName", "MethodName");
msg << 1;
QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
Log(QString(Get  :: [%1]").arg(reply.arguments().at(0)));

QDBusReply

QDBusReply<int> nReply = interface->call("MethodName");
nReply.value()



i writing...

if the source don't exist "default" in "Switch case" syntax ?

if the source don't exist "default" in "Switch case" syntax ?

this isn't error, but warning.

for example,

int test = 10;

printf("here 1");

switch (test) {
case 1:
break;
}

printf("here 2");


result console
here 1
here 2

you can show in this case, don't need to "default".
i think the compiler does write automatically.
but, this is warning.
i recommend to write "default".


little endianness, big endianness

엔디언(Endianness)은 컴퓨터의 메모리와 같은 1차원의 공간에 여러 개의 연속된 대상을 배열하는 방법을 뜻하며, 바이트를 배열하는 방법을 특히 바이트 순서(Byte order)라 한다.
엔디언은 보통 큰 단위가 앞에 나오는 빅 엔디언(Big-endian)과 작은 단위가 앞에 나오는 리틀 엔디언(Little-endian)으로 나눌 수 있으며, 두 경우에 속하지 않거나 둘을 모두 지원하는 것을 미들 엔디언(Middle-endian)이라 부르기도 한다.

바이트 순서는 크게 빅 엔디언과 리틀 엔디언으로 나눌 수 있다. 빅 엔디언은 사람이 숫자를 쓰는 방법과 같이 큰 단위의 바이트가 앞에 오는 방법이고, 리틀 엔디언은 반대로 작은 단위의 바이트가 앞에 오는 방법이다. PDP-11과 같은 몇몇 아키텍처는 2바이트 단위와 1바이트 단위로 서로 다른 순서를 사용하기도 하는데 이들을 미들 엔디언이라 부른다. 다음은 이런 방법들을 비교한 것이다.
종류0x1234의 표현0x12345678의 표현
빅 엔디언12 3412 34 56 78
리틀 엔디언34 1278 56 34 12
미들 엔디언-34 12 78 56
또는
56 78 12 34
두 방법 중 어느 한 쪽이 다른 쪽과 비교해 압도적으로 좋거나 나쁘지는 않다고 알려져 있으며, 두 방법은 서로 다른 여러 아키텍처에서 서로 공존하고 있다. 그러나 x86 아키텍처가 리틀 엔디언을 쓰기 때문에, 오늘날 x86 아키텍처를 사용하는 대부분의 데스크톱 컴퓨터는 리틀 엔디언을 쓰며 이를 ‘인텔 포맷’이라 한다. 거꾸로 네트워크에서는 주소를 빅 엔디언으로 쓰는데, 역사적으로 라우팅이 전화를 거는 식으로 접두 부호로 이루어졌기 때문이다. 이의 영향으로 많은 프로토콜과 몇몇 파일 포맷이 빅 엔디언을 사용하고 있다. 모토로라 프로세서들은 일반적으로 빅 엔디언을 사용하며, ARM 프로세서들은 성능 향상을 위해 빅 엔디언과 리틀 엔디언을 선택할 수 있도록 되어 있다.

빅 엔디언은 소프트웨어의 디버그를 편하게 해 주는 경향이 있다. 사람이 숫자를 읽고 쓰는 방법과 같기 때문에 디버깅 과정에서 메모리의 값을 보기 편한데, 예를 들어 0x59654148은 빅 엔디언으로 59 65 41 48로 표현된다.
반대로 리틀 엔디언은 메모리에 저장된 값의 하위 바이트들만 사용할 때 별도의 계산이 필요 없다는 장점이 있다. 예를 들어, 32비트 숫자인 0x2A는 리틀 엔디언으로 표현하면 2A 00 00 00이 되는데, 이 표현에서 앞의 두 바이트 또는 한 바이트만 떼어 내면 하위 16비트 또는 8비트를 바로 얻을 수 있다. 반면 32비트 빅 엔디언 환경에서는 하위 16비트나 8비트 값을 얻기 위해서는 변수 주소에 2바이트 또는 3바이트를 더해야 한다. 보통 변수의 첫 바이트를 그 변수의 주소로 삼기 때문에 이런 성질은 종종 프로그래밍을 편하게 하는 반면, 리틀 엔디언 환경의 프로그래머가 빅 엔디언 환경에서 종종 실수를 일으키는 한 이유이기도 하다.

reference: https://ko.wikipedia.org/wiki/%EC%97%94%EB%94%94%EC%96%B8
reference: https://en.wikipedia.org/wiki/Endianness

how to initialize array(C / C++)


case 1, 2, 3
int array[5] = { 0 };  VS int array[5] = { 0, };
and
memset(array, 0, 5);

case 1, 
int array[5] = { 0 };
=  array[0] = 0
    array[1] ~ array[4] = not initialized ? NO!
=  array[0] ~ array[4] = 0  Of Course, OK!

case 2,
int array[5] = { 0, };
=  array[0] ~ array[4] = 0  OK!

result :

int array[5]={0,1,2};
and
int array[5]={0,1,2,};

The elements array[4] and array[5] are automatically initialized to 0 in this case. 

the compiler take care of the rest(zero-initialize).


case 3,
memset(array, 0 , 5);

I don't recommend this case.
because you need to #include a special header(#include <cstring>).
and this case, all element is initialized to number 0.
so, you can't set to the value of 1 element and 2, ... .

snprintf : zero-length gnu_prntf format string

snprintf(str, sizeof(""), "")
--> sprintf(str, "");

zero-length gnu_printf format string

#C #C++ #sprintf #zero-length #gnu_printf #format string

PBAP(Phone Book Access Profile)


Phone Book Access Profile (PBAP) : the procedure and protocol for exchanging phone book objects between devices.

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...