[컴][폰] tfp0 patch


tfp0 patch 가 뭐지? patch 

tfp0 patch

task_for_pid

XNU 커널에서 task_for_pid는 privileged process가 동일한 host에 있는 다른 process의 task port를 가져 오도록하는 기능.

  • 커널 task (프로세스 ID 0)는 가져올 수 없다.

tfp0 패치

tfp0 패치 (또는 task_for_pid (0) 패치)는 이 제한(kernel task 를 가져올 수 없는 제한)을 제거한다.

  • 그래서 "root로 실행중인 모든 실행 파일"이 pid 0 (따라서 이름)에 대해 task_for_pid를 호출 하고, vm_read 및 vm_write를 사용하여 커널 VM 영역을 수정하는 것이 가능해 진다.
  • AMFI(AppleMobileFileIntegrity - The iPhone Wiki)를 만족 시키려면 get-task-allow 자격과 task_for_pid-allow 자격(entitlement)이 필요.

Reference

[컴][폰] 안드로이드 벤치마크 사이트


android benchmark test / benchmark site / 벤치마크 사이트 / 안드로이드 폰 비교 사이트 / 비교 분석 / 어느폰이 / 가성비 / 더 좋은 핸드폰 / 스마트폰 / 필터 / 필터링

안드로이드 벤치마크 사이트

  1. Android Benchmarks - Geekbench Browser : 리스트에 cpu 가 바로 보인다.
  2. PassMark Android Benchmark Charts
  3. Ranking - AnTuTu Benchmark - Know Your Android Better
  4. Cheap smartphone price comparison : 가격까지 filtering 이 가능하다.

[컴] vscode April 2020 (version 1.45) 에서 알게된 사실

유용한 vscode extension / 확장 / plugin / 플러그인 / vscode tips / vscode 팁들 / 코드 / vs코드 / 활용법 / github 이슈 관리 쉽게 / issue 관리 / issue 분리 방법 / github 와 vscode /

vscode April 2020 (version 1.45) 에서 알게된 사실



GitHub Pull Requests and Issues extension

그림에서 '2' 번 화살표를 누르면, branch 를 만들어 준다. 그리고 그 branch 를 사용중이면 '1' 처럼 'check' 표시가 보인다. 'master' branch 로 돌아오면 사라진다.(참고로 다른 branch 로 가면 사라지지 않는다.)

그리고 code 작성 완료후 'create pull request' 를 할 수 있다.

settings.json

  • githubIssues.useBranchForIssues 가 'on' 이면, 기본적으로 githubIssues.workingIssueBranch 로 branch 를 생성한다. 그래서 prompt 를 해주면 자신이 원하는 이름으로 branch 를 생성할 수 있다.
  • githubIssues.queries: 원하는 형태로 정렬해서 list 와 대략적인 내역을 확인할 수 있다.
"githubIssues.queries": [
    {
        "label": "My Issues",
        "query": "author:${user} state:open"
    },
    {
        "label": "Created Issues",
        "query": "author:${user} state:open repo:${owner}/${repository} sort:updated-desc"
    }
],
"githubIssues.useBranchForIssues": "prompt", // on
"githubIssues.workingIssueBranch": "feature/issue${issueNumber}",
"githubPullRequests.telemetry.enabled": false,


githubIssues.createIssueTriggers

editor 에서 TODO 등을 치면 아래처럼 github issue 를 생성하는 메뉴가 보인다.




[컴] nodejs 에서 pdf 생성 및 download

client 에서 download 하기 / ajax 로 다운로드하는 방법 / download with ajax / node js download file 하는 방법

nodejs 에서 pdf 생성 및 download

pdfkit 사용법

doc.end() callback

기본적으로 doc.end() 가 되었다고 writeStream 이 끝나지 않는다. 그래서 on('close', callback) 관련 코드를 작성해줄 필요가 있다.

  async generate(data) {
    
    const that = this;
    const promise = new Promise((resolve, reject) => {
      // ref: https://github.com/foliojs/pdfkit/issues/265#issuecomment-246564718

      // To determine when the PDF has finished being written successfully 
      // we need to confirm the following 2 conditions:
      //
      //   1. The write stream has been closed
      //   2. PDFDocument.end() was called syncronously without an error being thrown

      let callCount = 2;
      const onClose = () => {
        callCount--;
        if (callCount === 0) {
          resolve();
        }
      }
      const onError = (e) => {
        reject(e);
      }

      // Pipe its output somewhere, like to a file or HTTP response
      // See below for browser usage
      const { writeStream, outFilePath } = that._createWriteStream();

      that.outFilePath = outFilePath;

      writeStream.on('close', onClose);
      writeStream.on('error', onError);

      const doc = new PDFDocument({
        size: [595, 842], // A4, 72dpi
      });;

      doc.pipe(writeStream);

      ...

      // Finalize PDF file
      doc.end();
      onClose();

      return;
    });

    const res = await promise;
    return res;
  }

ajax download

server side with andonijs

async genR2RPdf({ request, auth, response }) {
  ...
  
  try {
    
    ...
    const pgen = new MyPdfGen();
    await pgen.generate(data);
    const filepath = pgen.getOutFilePath(data);
    
    return response.attachment(filepath, `${inputData.ym}_cfstyle.pdf`);
    // return response.download(filepath); <--- 이것을 사용해도 된다.
  } catch (e) {
    Logger.error(e.stack);
    return response.status(400).json({ error: 'run_error', errors: e.message });
  }
}

client side

import 
 from 'axios';

class DownloadButton extends React.Component {
  ...
  _onClickR2rDownload(e) {
    // pdfgen
    const token = localStorage.getItem('ft');
    const auth = `Bearer ${token}`;
    const config = {
      headers: { 'Content-type': 'application/json', Authorization: auth },
      responseType: 'blob',
    };

    const fileLink = this.downloadEl;
    return axios.get(`/my/pdfgen?user_id=10`, config)
      .then((res) => {
        if (res.constructor === Error) {
          throw res;
        }
        if (res.status === 200) {
const fileURL = window.URL.createObjectURL(new Blob([res.data])); fileLink.href = fileURL; fileLink.setAttribute('download', 'file.pdf'); fileLink.click();
URL.revokeObjectURL(fileLink.href); // ref. 2 를 참고하자 } }).catch((error) => { console.error('Error during service worker registration:', error); }); } render(){ return( <div> <a ref={(el) => { this.downloadEl = el; }} /> <button type="button" onClick={this.onClickDownload}> 다운로드 </button> </div> ) } }


See Also

  1. vue.js - Vue/HTML/JS how to download a file to browser using the download tag - Stack Overflow
  2. https://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file/32295448#32295448 

[컴][네트워크] 라우팅 프로토콜

routing protocol / router / 라우팅 프로토콜  / 어떻게 패킷이 가는가 / 네트워크 알고리즘


라우팅 프로토콜

routing protocol은 3가지 형식으로 분류할 수 있다.
  1. routing table 을 누가 만드느냐에 따라 분류
  2. 내부 network에서 routing을 담당하느냐에 따른 분류
  3. routing table을 어떻게 만드느냐에 따른 분류

routing table 을 누가 만드느냐에 따라 분류

스태틱 라우팅 프로토콜(static routing protocol)

  • 사람이 직접 손으로 routing table(라우팅 테이블)을 만드는 것이다.
  • 경로에 문제가 발생하면, 다시 사람이 고쳐주지 않는 한 문제를 해결하지 못한다.

다이나믹 라우팅 프로토콜(dynamic routing protocol)

  • 라우터가 알아서 routing table을 만들어 준다.
  • 경로 이상 시 알아서 다른 경로를 설정할 수 있다.
  • 하지만 라우터의 부담이 가중된다.
  • RIP, IGRP, OSPF, EIGRP 등이 있다.

내부 network에서 routing 을 담당하느냐에 따라

  • IGP(Interior Gateway Protocol)
  • EGP(Exterior Gateway Protocol) 로 나눌 수 있다.
같은 관리자의 관리 하에 있는 라우터의 집합을 AS(Autonomous System)라고 하는데,
Autonomous System 내에서 사용되는 router 의 protocol 이 IGP이다. RIP, IGRP, EIGRP, OSPF 이 여기에 속한다.
그리고 AS와 다른 AS 사이에서 사용되는 router의 protocol이 EGP이다. BGP, EGP 이 여기에 속한다.


routing table을 어떻게 관리하는 가에 따라

  • 디스턴스 벡터 알고리즘(Distance Vector Algorithm)을 사용하는 프로토콜,
  • 링크 스테이트 알고리즘(Ling State Algorithm)을 사용하는 프로토콜
DVA 는 routing table 에 목적지까지 가는데 필요한 거리와 방향만을 기록. RIP와 IGRP가 대표적이다
LSA 는 라우터가 목적지까지 가는 경로를 SPF(Shortest-Path-First) 알고리즘이란 것을 통해 routing table에 기록. OSPF가 대표적이다.



[컴][네트워크] 인터넷 속도 측정하는 사이트

internet speed measurement / 인터넷 속도 / 스피드 측정 방법 / 측정 사이트 / 속도 확인 방법 우클라 / netflix /isp / 넷플릭스 보기 좋은 인터넷 /

인터넷 속도 측정하는 사이트

둘의 측정방식이 어떤 차이를 가지는지는 모르지만, 두 사이트의 값은 다르게 나온다.

See Also

[컴] ARM 의 license

Apple 의 CPU(A4, A5, A6 …) / Qualcomm 의 Snapdragon / 삼성의 Exynsos / 애플의 cpu 와 삼성의 cpu 의 차이 / 삼성의 비메모리 반도체 수준


qualcomm 의 snapdragon 이나 삼성의 엑시노스(Exynose) 와 차이가 궁금해서 조금 찾아봤다.

여기서 말하고자 하는 결론은 "Microarchitecture" 의 차이가 있다." 이다.

퀄컴도 삼성도, 그리고 애플도 전부 ARM core 를 사용한다. 처음 생각에는 이 ARM core 를 license 하는 거면, 결국 그냥 설계도 license 해서 fab(공장) 에 의뢰해서 찍어내면, core 는 다 비슷한 것 아닌가 라고 생각했다. 물론 SoC 이기 때문에 안에 들어가는 녀석들에 대한 디자인이나, 다른 core(GPU 같은) 들이 다른 성능을 가지기 때문에 그 부분이 다른 것이라고 생각했다.

ARM 의 license

그런데, 잘 못 알고 있었다. 알고 보니, ARM license 가 아래와 같이 2가지가 있다[ref. 1].
  • processor core license : Cortex A8, A9, A15…
  • ARM instruction set architecture license : ARMv7 ISA
core license 를 가진 경우에는 그냥 찍어내면 되는 것이고, instruction set architecture(ISA) 이 관한 license 가 있는 경우에는 ARM instruction set 을 기반으로 자신들이 알아서 원하는 대로 구현을 하는 것이다.

license a specific processor core (e.g. Cortex A8, A9, A15)

  • Some Qualcomm SoCs (e.g. the MSM8x25/Snapdragon S4 Play uses ARM Cortex A5s)
  • Apple A5 : Cortex-A9
  • Apple A4 : Cortex-A8
  • Samsung : Exynose seriese

license an ARM instruction set architecture (e.g. ARMv7 ISA)

  • Qualcomm Scorpion/Krait
  • Apple A6 : Swift; ARMv7-A compatible

Arm Flexible Access for Startups

ARM 이 2020년 4월30일에 발표한 새로운 라이센스 정책이다.[ref.8]

새로운 정책은 처음(early-stage, $500만 달러이하 펀딩을 받은 스타트업) 에는 돈을 안내고, 그들이 상업적인 실리콘과 비지니스 규모가 되면 그때 돈을 받는 구조이다.


A6, Exynos, Snapdragon

Apple 이나 Qualcomm 은 이 두 가지 license 를 모두 갖고 있는 듯 하다.[ref. 1]

여하튼 그래서 Apple 은 A6 부터 자신만의 CPU 를 design 해서 만들기 시작한 듯 하고[ref. 1], Qualcomm 은 Scorpion 이라고 불리는 시점부터 아니면 그 이전부터 자신들이 직접 core 를 디자인 한 듯 하다.

삼성의 Exynos 는 아직 그런 수준에 이르지는 못한 것으로 보인다. 적어도 지금까지 나온 Exynos 의 사양을 보면 ARM processor core 를 license 해서 그대로 쓰고 있는 듯 보인다.[ref. 6] ref.7 을 보면 이제 더이상 core 개발을 하지 않는다고 한다.

물론 직접 디자인 한 것이 꼭 좋다고는 할 수 없겠으나, ARM 쪽에서 특정 vendor 만을 위한 core design 을 해 줄 까닭이 없기 때문에 아무래도 이런 능력을 가지고 있으며, 자신의 제품을 만들고 있는 Apple 쪽의 전망이 유망해 보이기는 한다.

References

  1. The iPhone 5's A6 SoC: Not A15 or A9, a Custom Apple Core Instead, 2012. 9월. 15
  2. Difference Between Apple A5 and Qualcomm Snapdragon S3, 2011.11월. 13
  3. http://en.wikipedia.org/wiki/Apple_A4
  4. http://en.wikipedia.org/wiki/Apple_A5
  5. http://en.wikipedia.org/wiki/Apple_A6
  6. http://en.wikipedia.org/wiki/Exynos_(system_on_chip)
  7. 삼성전자, 자체 CPU 코어 개발 중단…"NPU·GPU에 역량 집중" - 전자신문
  8. Arm Offers Startups Zero-cost Access to its IP Portfolio | TechPowerUp, 2020-04-30