jngsoo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 서울숲_P_Day14 ## 0. 참석자 - 김예지, 신정수, 임성연, 최우혁 ## 1. 코드 동작 이해 - 화면 입력(출근 수)에 따른 baristar(`Worker`)의 수를 정한다. - 화면 입력(주문)에 따른 orderQueue를 채운다. - Manager와 cafe에서 baristar로 작업을 보낸다. - 모든 작업을 종료하면 프로세스를 종료한다. - baristar와 Manager는 Web Worker로 background에서 동작한다. - Worker는 message event를 기반으로 비동기로 동작한다. #### Web Worker의 postmessage 와 onmessage 동작 이해 - [Worker객체].postmessage([보낼 메세지(데이터)]) 를 통해 브라우저에서 쓰레드로 동작하는 해당 worker 객체에 메세지를 보낼 수 있음. - 메세지(데이터)를 받은 해당 Worker는 onmessage 를 이용해 받은 메세지(데이터)를 어떻게 처리할 지 정할 수 있음. - 메세지(데이터)를 처리한 해당 Worker는 다시 postmessage를 통해 처리한 데이터를 데이터를 보냈던 script로 다시 보내게 된다. - script에서는 다시 [Worker객체].onmessage 를 사용해 Worker가 보내준 데이터를 어떻게 처리할 지 명시할 수 있다. ``` Cafe Start baristarNum input => Make baristars, manager order input => Make OrderQueue while not orderQueue empty if Manager check baristars free Manger.postMessage(baristar to OrderQueue.shift) Cafe End baristar Start if on Message time <= kindOfCoffe(3, 5, 10) work during time End ``` ## 2.코드 동작 개선 - HTML form tag 사용시 이슈 - html form tag를 사용해 입력받은 데이터를 submit 할 경우, html 문서에 결과가 잠시 나타났다가 바로 없어지는 문제점이 공통적으로 나타남. - form 태그 안에 action 속성값을 주지 않았고, submit 시 현재 페이지가 새로고침이 되어 해당 문제가 발생했던것. - form tag 동작 방식 - 폼 안에 입력 된 데이터를 웹 서버는 받은 폼 데이터를 처리하기 위해 웹 프로그램으로 넘긴다 - 웹 프로그램은 폼 데이터를 처리하고 그 결과에 따른 새로운 html 페이지를 웹 서버에 보낸다. - 이후 웹 서버는 받은 html 페이지를 브라우저에 보내고, 브라우저는 받은 html 페이지를 보여준다. - Server 구동 - 해당 작업은 Web API를 이용해 구현한다. - Cafe = 하나의 web Model로 구현한다면 Manager와 Cafe에 대한 모듈의 분리가 가능할 것이다. - manager worker와 barista worker 간의 메시지 요청 - manager worker내에서 barista worker에 postmessage를 하면 두 워커간에 메시지 요청을 할 수 있다. ## 3.Consideration ### 3-1. 스스로 확인할 사항 - Process Scheduling : - 비선점 스케줄링 : 작업중인 Thread를 조작할 수 없는 스케줄링 기법 - FCFS / SPN 등의 알고리즘 활용 - FCFS : 준비큐에 먼저 도착한 프로세스를 스레드에 할당하고 이를 반납할때까지 계속 사용한다. (이번에 작업한 방식) - SPN : 준비큐에서 CPU요구량이 낮은 것 부터 처리한다. - 응답시간의 예측이 용이하다 - 선점 스케줄링 : 작업중인 Thread더라도 더 우선순위의 작업이 Thread를 빼앗을 수 있는 기법 - SRT, 다단계 큐 등의 알고리즘이 있다. - SRT : 더 적은 시간이 후에 들어올 경우 interupt하여 실행한다. - 다단계 큐 : 준비큐를 우선순위에 맞추어 여러개 구성하고 상위 큐부터 실행하는 방식 / 상위큐가 들어오면 interupt하여 실행한다. - 빠른 응답시간을 요구할 때 활용된다. (대화식 시분할 시스템) - 오버헤드(간접 처리 시간)가 증가한다. - 참고자료 : https://coding-factory.tistory.com/309 - setTimeout 동작 방식 : - 함수가 호출되어 callStack에 쌓이게 되면 바로 브라우저 또는 nodeJS의 webAPI로 callback 함수와 delay시간이 넘어간다. 시간이 지나면, callback함수를 taskQueue의 마지막에 추가한다. ### 3-2. 다같이 확인할 사항 #### setTimeout 이 외에 timer를 구현하기 위한 여러 방식에 대해 학습한다. - while문에 delay를 이용하여 customSleep을 구현할 수 있다. 이는 동기적인 방식으로 V8엔진 내에서 싱글스레드로 작동된다. #### 멀티 스레드가 공용 리소스에 접근할 때 임계구역을 다루는 방식에 대 학습한다. (Semaphore, Mutex 등) - Mutex : 공용 리소스가 heap 에 올라갈 때 lock을 걸어 한번에 하나의 스레드가 공유자원에 접근하게 한다. - Semaphore : 공용 리소스의 개수를 나타내는 변수를 통해 한번에 하나의 프로세스가 공유자원에 접근하게 한다. #### 멀티 스레드 작업을 그룹으로 묶어서 동기화하는 방식에 대해 학습한다. - 스레드는 하나의 프로세스의 자원을 공유 - 프로세스별로 스레드들을 그룹으로 묶어, 각 프로세스 별로 공유하는 자원들에 대해 동기화에 대한 문제들이 발생하지 않도록, 각 프로세스의 스레드들이 공유자원에 대해 mutex, semaphore 등의 방식을 사용해 동기화하여 동작하도록 한다. - 여러 스레드들이 동기 형태로 실행된 결과(각 스레드의 결과들)를 하나로 모아 정리하는 방식으로 사용 가능. - Web worker에서 group method를 통해 cpu의 개수만큼 worker를 생성해 동시에 프로세스를 할당 할 수 있다. - map / thru / reduce / then에 작업 이름을 등록함으로써 worker가자동으로 작업을 할당하고 수행하여 merge_sorted를 통해 데이터를 처리할 방식을 설정한다. - 출처 http://blog.naver.com/PostView.nhn?blogId=pjt3591oo&logNo=221319367562&parentCategoryNo=&categoryNo=55&viewDate=&isShowPopularPosts=true&from=search

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully