Advance Innovation Centre
  • AIC Knowledge @ EEC for All
  • 😎Logical Thinking
    • Karel Robot
    • Code to Flowchart
    • Play with Docker
    • CNX Software
  • MCU & Interfacing with Infineon PSOC™
    • Basic MCU Interfacing
      • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
      • Development Environment Preparation
      • PSoC™ 6S2 Peripherals Interfacing (GPIO)
        • Hello World and LED Blinking
        • GPIO Principles
        • PSoC™ 6S2 GPIO-HAL LED Blink Lab
        • PSoC™ 6S2 GPIO-PDL LED Blink Lab
        • Button "Bounce" Principles
          • Push/Pull Button to Turn ON/OFF LED via HAL
          • Push/Pull Button to Turn ON/OFF LED via PDL
          • GPIO Button Interrupt via HAL
          • GPIO Button Interrupt via PDL
        • GPIO variables & functions
      • PSoC™ 6S2 Peripherals Interfacing (ADC, PWM)
        • PSoC™ 6S2 SAR ADC
          • ADC Principles
          • PSoC™ 6S2 with ADC Labs
            • Reading potentiometer sensor value via an ADC HAL
            • Reading potentiometer sensor value via an ADC PDL
        • PSoC™ 6S2 PWM & TCPWM
          • PWM Principles
          • PSoC™ 6S2 for PMW Function Labs
            • LED Brightness using PWM via HAL
            • LED Brightness using PWM via PDL
    • Sensor Interfacing and HMI
      • OLED Display
        • OLED Display Principles
        • Calling BDH’s OLED functions
        • Display ADC via Potentiometer on OLED
      • BDH Shell
        • Shell Principles
        • LED Blinking and CAPSENSE via BDH Shell
        • Adding "History" command
        • Adding "Reboot" command
        • CAPSENSE Button and Slider
          • CAPSENSE Button and Slider with Capsense Tuner
          • CAPSENSE Button and Slider using FreeRTOS
    • Serial Communication & Visualization
      • UART, I2C, SPI Communication via Infineon PSoC™6
      • BMX160 Sensor Communication via Infineon PSoC™6
        • Reading ADC via HAL with Potentiometer and Displaying GUI on Serial Studio
        • Reading XENSIV-DPS-3XX Pressure Sensor and Displaying GUI on Serial Studio
        • Motion Sensors GUI Integration via Serial Studio
    • IoT Connectivity & Data Analytics via Node-Red
      • Node-Red Installation
      • Setting MQTTS to MQTT Broker
      • Sending PSoC6’s sensor to MQTT (node-red)
    • Edge AI on PSoC™
      • Machine Learning on PSoC™6 via Edge-Impulse
    • Infineon PSoC™ Troubleshooting
  • IoT Development with Infineon PSOC™ & BDH Platform
    • PSoC™ IoT Development Kit
      • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
      • Development Environment Preparation
        • Hello World and LED Blinking
    • IoT Connectivity
      • Node-Red Installation
      • Controlling PSoC™ LED using MQTT
      • Setting MQTTS to MQTT Broker
      • Sending PSoC6’s sensor to MQTT (node-red)
    • BDH IoT Connectivity
    • WireLinX™ IoT PLC
    • BDH X-Brain Data Analytics
      • PSoC6 Data Collection to CSV log file
    • Data Visualization
      • สร้าง Dashboard ด้วย Looker Studio
  • 🖥️Operation Systems
    • Prerequisites
      • Guideline from Ubuntu
        • Ubuntu and VSCode on WSL2
      • ติดตั้ง WSL 2
      • Run Ubuntu on VirtualBox7
    • Zero to Linux Hero
      • Computer OS Architecture
      • Anatomy of Linux System
        • UNIX/Linux History
        • UNIX/Linux Evolution
        • GNU Project
        • Linux OS Architecture
        • Command Line Interface (CLI)
          • Basic Commands
          • 😎Level up your Linux Shell
          • File & Dir. Commands
          • Searching Commands
          • 😎ChatGPT-based Terminal
          • SysAdmin Commands
          • Network Commands
          • Hacker Commands
        • Busybox
        • Shell Script
          • Awk Script
          • Bash Shell Script
            • Bash Snippets
            • Bash Useful Examples
      • Anatomy of Linux Kernel
        • Linux Kernel Principles
        • Linux Environment for Developer
      • Anatomy of Embedded Linux
        • Embedded Linux
        • Host & Target
        • Cross Toolchains
        • Bootloader
        • Building Embedded Linux
    • Linux OS Dev. Engineer
      • Process Management
        • Process Basic
        • Process State
        • Basic Process Mgmt. Commands
        • Advance Process Mgmt. Commands
        • Process API Programming
      • IPC
        • IPC Anatomy
        • Signal Programming
        • Pipe Programming
        • FIFO Programming
        • Msg. Queue Programming
          • System V
        • Share Memory Programming
          • System V
        • Socket Programming
      • POSIX Threads
        • Multi-tasking Basic
        • POSIX Thread Anatomy
        • Threading Programming
      • Applied IPC
        • Remote Commander
        • Multi-Remote Commanders
      • Process Synchronization
        • Mutex Programming
        • Semaphore Programming
      • Applied IPC with Semaphore
  • ⌚Embedded Systems Development
    • Introduction to ESD
      • Why's ESD?
      • What it use for?
      • How it works?
    • Enbedded System Development via PSoC6
      • Basic MCU Interfacing
        • Introduction to CY8CKIT-062S2-43012 Pioneer Kit
        • Development Environment Preparation
        • PSoC™ 6S2 Peripherals Interfacing (GPIO)
          • Hello World and LED Blinking
          • GPIO Principles
          • PSoC™ 6S2 GPIO-HAL LED Blink Lab
          • PSoC™ 6S2 GPIO-PDL LED Blink Lab
          • Button "Bounce" Principles
            • Push/Pull Button to Turn ON/OFF LED via HAL
            • Push/Pull Button to Turn ON/OFF LED via PDL
            • GPIO Button Interrupt via HAL
            • GPIO Button Interrupt via PDL
          • GPIO variables & functions
        • PSoC™ 6S2 Peripherals Interfacing (ADC, PWM)
          • PSoC™ 6S2 SAR ADC
            • ADC Principles
            • PSoC™ 6S2 with ADC Labs
              • Reading potentiometer sensor value via an ADC HAL
              • Reading potentiometer sensor value via an ADC PDL
          • PSoC™ 6S2 PWM & TCPWM
            • PWM Principles
            • PSoC™ 6S2 for PMW Function Labs
              • LED Brightness using PWM via HAL
              • LED Brightness using PWM via PDL
      • Sensor Interfacing and HMI
        • OLED Display
          • OLED Display Principles
          • Calling BDH’s OLED functions
          • Display ADC via Potentiometer on OLED
        • BDH Shell
          • Shell Principles
          • LED Blinking and CAPSENSE via BDH Shell
          • Adding "History" command
          • Adding "Reboot" command
          • CAPSENSE Button and Slider
            • CAPSENSE Button and Slider with Capsense Tuner
            • CAPSENSE Button and Slider using FreeRTOS
      • Serial Communication & Visualization
        • UART, I2C, SPI Communication via Infineon PSoC™6
        • BMX160 Sensor Communication via Infineon PSoC™6
          • Reading ADC via HAL with Potentiometer and Displaying GUI on Serial Studio
          • Reading XENSIV-DPS-3XX Pressure Sensor and Displaying GUI on Serial Studio
          • Motion Sensors GUI Integration via Serial Studio
    • Edge Computing and IoT Connectivity
    • Cloud-Based Data Analytics and Digital Twin
    • Edge Vision AI
    • Resources
      • Basic Hardware and Firmware
        • Environment Preparation
          • การติดตั้งโปรแกรม Arduino IDE
            • ตัวอย่างการเริ่มต้นใช้งาน Arduino IDE
          • การติดตั้งโปรแกรมสำหรับใช้งานเครื่องมือวัด NI MyDAQ
            • ตัวอย่างการตั้งค่าใช้ Digital Multimeter -NI ELVISmx
            • ตัวอย่างการตั้งค่าใช้ Oscilloscope-NI ELVISmx
          • ติดตั้งโปรแกรม KingstVIS
        • Basic measurement
          • Basic Digital and Analog I/O
            • LAB: Basic Digital Input/Output
            • LAB: Basic Analog Input/Output
          • Waveform
            • LAB: Oscilloscope
            • LAB: Oscilloscope and Function Generator
            • LAB: Pulse Width Modulation (PWM)
              • Homework
        • Interfacing and Communication
          • LAB: UART, RS485, RS232 Protocol
          • LAB: I2C Protocol
            • HOMEWORK
          • LAB: SPI Protocol
      • IoT Connectivity
        • Example: IoT with MQTT on Node-red
        • Data logger
        • LAB: Data Visualization
  • 🛠️C/C++ for Embedded Programming
    • Development Environment Preparation
      • ติดตั้ง WSL 2
      • ติดตั้ง Ubuntu environment
      • ติดตั้งโปรแกรม Visual Studio Code
      • การเชื่อมต่อ Virtual studio code เข้ากับ WSL
      • ติดตั้ง docker on WSL
    • Principle C/C++ Programming
      • Get started with C++
      • Makefile
        • Makefile Examples
      • Compiling and running
        • How to create a program that you can enter inputs.
          • Lab 1 Exercise
      • Arguments
        • Command line arguments in C and C++
      • signed and unsigned data types
      • Variable and Operator
      • If and If else
      • Loop, Infinite loop, and flag
        • Loop and Flag exercise
      • Array
        • Get to know with arrays
        • Implement example
      • Vector
    • Object Oriented Programming (OOP) in C++
      • Class and Object
      • Encapsulation and Abstraction
      • Polymorphism and Inheritance
    • C/C++ Preprocessing
      • Macro
        • Quiz Macro
      • File Inclusion
      • Conditional Compilation
      • Pragma directive
        • Quiz Pragma
    • String in C++
      • Concatenation
      • Split
    • Type conversions for C/C++
      • Conversion using Cast operator
    • Error handling
    • Data logger
      • การสร้างไฟล์และเขียนไฟล์
      • การอ่านไฟล์
      • การเก็บข้อมูลกับTime stamp
    • High performance programing
      • Multi-task and Multi-thread
        • Multi-threading example
      • Mutex
      • Queue
      • OpenCV
    • C/C++ Techniques
      • Makefile in action
      • Object Oriented Programming (OOP) in C++
        • Class and Object
        • Encapsulation and Abstraction
        • Polymorphism and Inheritance
      • C/C++ Preprocessing
        • Macro
          • Quiz Macro
        • File Inclusion
        • Conditional Compilation
        • Pragma directive
          • Quiz Pragma
      • Binary, Octal and Hexadecimal Numbers
      • Array and properties of an array
        • Get to know with arrays
        • Implement example
      • What's next?
  • 🤖Artificial Intelligence (AI)
    • VAMStack Design House, BUU
    • Data Analytics
      • Data cleansing
      • Data analytics
      • Data analytic exercise
    • Machine Learning
      • Neural Network Layers
      • Machine learning type
      • Dataset
      • Using Edge Impulse for AI Model
    • Basic Image Processing
      • Computer Vision using Python Language
        • Installation
        • Computer Vision Basics
          • Pixel and Color
          • Draw image
          • Basic Image processing
          • Morphology Transformations
          • Gaussian blur
          • Simple Thresholding
          • Contour
          • Canny edge detection
        • Case Study
          • Coin counting
          • Color detection & tracking
        • VAM_CV SDK
  • ⚙️FPGA Design and Development
    • Verilog HDL via Vivado IDE
      • LAB1: Setting Environment and Create Project
        • Create Vivado Project
      • LAB2: Hardware Description Language Work Flow
        • Simulation code
      • LAB3: Design HDL Project
        • Top Level Design
        • Top-level Simulation
      • LAB4: Asynchronous VS Synchronous Circuit
        • Simulation Synchronous counter
    • C/C++ Programming on Ultra96v2 FPGA Board
      • Application C/C++ on Ultra96v2 Part 1
        • Design Overview
        • Step 1 - Burn the image to SD card
        • Step 2 - Bring up Ultra96v2
        • Step 3 - Installing the Vitis-AI runtime packages
      • Application C/C++ on Ultra96v2 Part 2
        • STEP 1 : Setting auto boot Wifi
        • STEP 2 : How to working on Embedded
        • STEP 3 : How to run the test code
  • 🤖Robotics
    • Dobot Magician
      • Instruction of Dobot
      • Software Download
      • Basically of Program
        • Teaching and Playback
        • Write and Draw
        • LaserEngraving
        • 3D Printer
    • Robotino
      • Software Download
        • Robotino View
        • Robotino SIM
      • Charging
      • Connecting
      • Follow Line example
        • Basic block in Follow Line
    • RaspBlock
      • Get Started with Raspblock
  • 🚩Special Topics
    • Node-Red
      • Set up Raspberry Pi
      • Install node red in Raspberry Pi
      • Get started with Node Red
        • Open node-red
        • Turn off node red
        • Install Dashboard on Node-red
        • Use node red to show message
        • Using Ultrasonic sensor with node-red
    • IoT Cloud
      • Overview
        • How do they work?
          • Basic Knowlege
      • Installations
        • Install Docker
        • Install Mosquitto Broker
        • Install InfluxDB
        • Install Telegraf
        • Install Grafana
      • Get Sensor Value and Send to MQTT
        • Connect ESP3266 to sensor
        • Connect ESP3266 to MQTT
      • Integration
    • Senses IoT
      • SENSES IoT Platform
      • LAB8: MCU send data to IoT platform
    • CrowPi Dev Kit
      • Raspberry Pi with CrowPi
      • Remote to Raspberry Pi
      • Cross-Compile
        • Lab 1: Programming and cross complier
      • Hardware and Interfaces Usage CLI
        • LAB: Usage GPIO via CLI
        • LAB: Scan I2C bus via CLI
      • Python library for Crow Pi
      • wiringPi library (C) for CrowPi
        • Lab2: Crowpi and sensors
    • LVGL Development
      • LVGL - Light and Versatile Embedded Graphics Library
        • Setting program for LVGL Simulator
        • Get started with LVGL simulator
        • Example Library of LVGL
        • Create your own screen
          • Exercise
        • Style
          • Exercise
        • Event
    • Docker OS
      • Docker OS Part 1
        • Part 1 : Installation
        • Part 2 : Basic Docker OS and Linux CLI
      • Docker OS Part 2
        • Part 1 : Docker communication
        • Part 2 : Docker compose
      • Application Gstreamer on devcontainer
        • STEP 1 : Setting gstreamer environment
        • STEP 2 : Create the Gstreamer element on template
        • STEP 3 : Testing and application on your gst element
  • 🤟Recommended by AIC
    • Skill Roadmap
      • Embedded Engineer
      • Developer
    • Hardware Programming
    • Embedded Programming
    • General-propose Programming
    • Algorithmica
    • Thai Expert Knowledge
    • RT-Thread University Program
      • Infineon PSoC6
      • Kernel
        • Kernel Basics
        • Thread Management
        • Clock Management
        • Inter-thread synchronization
        • Inter-thread communication
        • Memory Management
        • Interrupt Management
        • Kernel porting
        • Atomic Operations
        • RT-Thread SMP
        • Kernel API Changelog
      • Tools
      • Devices & Drivers
        • SENSOR Devices
        • Touch Equipment
        • CRYPTO Devices
        • AUDIO Devices
        • Pulse Encoder Devices
      • Components
        • C Library (libc)
        • ISO/ANSI C Standard
        • POSIX Standard
          • FILE (File IO)
          • Pthread
          • Timer
          • IPC Semaphore
          • IPC Message Queues
          • Dynamic Modules
        • Network Components
          • FinSH Console
          • FAL: Flash Abstraction Layer
          • Virtual File System
          • tmpfs: temporary file system
          • ulog log
          • utest testing framework
          • Power Management
          • RT-Link
        • Software Packages
          • Internet of Things
            • MQTT-umqtt
            • Telnet
          • Tools
            • SystemView
            • SEGGER_RTT
          • LVGL Manual
            • Touch Screen Driver
      • Demo
        • Infineon Gateway
        • Handwriting Recognition (MNIST)
        • Object Detection (Darknet)
        • ROS using RT-Thread
        • Control the car using RT-Thread
        • LiDAR via RT-Thread
        • Detection via RT-Thread and ROS
        • Sensor Driver Development Guide
Powered by GitBook

Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University

On this page
  • รายละเอียดของแต่ละชั้นภายในสถาปัตยกรรมของระบบปฏิบัติการลีนุกซ์
  • A history of shells

Was this helpful?

  1. Operation Systems
  2. Zero to Linux Hero
  3. Anatomy of Linux System

Linux OS Architecture

Linux Kernel และ Shell Architecture

PreviousGNU ProjectNextCommand Line Interface (CLI)

Last updated 1 year ago

Was this helpful?

ตั้งแต่ที่ Andrew Tanenbaum ได้สร้าง Microkernel () version of UNIX® ที่เรียกขานกันว่า "MINIX" (for minimal UNIX) สำหรับให้สามารถใช้งานได้บนเครื่องคอมพิวเตอร์ส่วนบุคคลขนาดเล็ก ทำให้ Linus Torvalds (early 1990s)

โครงสร้างพื้นฐานภายในระบบปฏิบัติการลีนุกซ์ซึ่งมีเคอร์เนลเป็นตัวเชื่อมโยงกลางระหว่างโปรแกรมระบบ และระบบฮาร์ดแวร์ ซึ่งเคอร์เนลนั้นจะถูกห่อหุ้มโดยเชลล์ (Shell) ที่มีด้วยกัน 2 ส่วนคือ CLI (Command Line Interface) และ GUI (Graphic User Interface) ส่วนชั้นนอกสุดจะเป็นส่วนโปรแกรมสำหรับผู้ใช้ดังแสดงในรูปข้างล่าง

รายละเอียดของแต่ละชั้นภายในสถาปัตยกรรมของระบบปฏิบัติการลีนุกซ์

จากรูปโครงสร้างสถาปัตยกรรมของระบบปฏิบัติการลีนุกซ์ข้างล่าง ส่วนของชั้นบนสุดจะเป็นส่วนของโปรแกรมประยุกต์ต่างๆสำหรับให้ผู้ใช้ได้เรียกใช้งานได้ ซึ่งสามารถเรียกไปยังเคอร์เนลได้ 2 ทางคือผ่าน GNU C Library และเรียกตรงไปยัง System Call Interface (SCI) โดยที่โปรแกรมสำหรับผู้ใช้ และ GNU C Library นั้นจะอยู่ในพื้นที่ส่วนของผู้้ใช้ที่เรียกว่า User Space

ในส่วนของพื้นที่ที่สำคัญมากอีกส่วนคือ Kernel Space ซึ่งประกอบไปด้วย SCI, เคอร์เนล และส่วนเคอร์เนลที่ขึ้นอยู่กับชนิดของสถาปัตยกรรมนั้นๆ เรียกกันว่า Board Support Package (BSP) โดยตัว SCI จะมีบทบาทสำคัญที่เป็นตัวกลางให้กับโปรแกรมประยุกต์ต่างๆ รวมทั้ง C Library ทั้งหมดเพื่อรองรับการเรียกใช้เคอร์เนลของระบบในการขอเข้าถึงระบบฮาร์ดแวร์ต่างๆ

ตัวอย่างการทำงานเช่นเมื่อผู้ใช้ต้องการจะเปิดอ่านไฟล์ที่ถูกเก็บอยู่ใน USB Storage ผู้ใช้ก็จะทำการเรียกใช้โปรแกรมประยุกต์ตัวหนึ่งขึ้นมา โดยภายในโปรแกรมประยุกต์นั้นจะต้องเรียกใช้ฟังก์ชัน read/write ไฟล์ที่เป็นฟังก์ชันภายใน GNU C Library ซึ่งจะเรียกตรงไปยังฟังก์ชันภายใน System Call อีกต่อนึง เมื่อต้องการเปิดไฟล์ที่ถูกเก็บอยู่ใน USB Storage ตัวเคอร์เนลก็ต้องรู้วิธีการเข้าถึงระบบไฟล์ (File System) ที่ USB Storage นั้นใช้อยู่ เช่น FAT32 ดังนั้นตัวคอร์เนลจะต้องใช้ฟังก์ชันไดรเวอร์ภายในเคอร์เนลเพื่อเข้าถึงไฟล์ตามรูปแบบมาตราฐานโปรโตคอลของในระบบไฟล์ชนิด FAT32

จากโครงสร้างข้างต้น แต่ละชั้นมีรายละเอียดดังนี้

  • Hardware Layer - อุปกรณ์ฮาร์ดแวร์ภายในบอร์ด ตัวอย่างเช่น หน่วยประมวลผลขนาด 32 บิตขึ้นไป หน่วยจัดการหน่วยความจำ (MMU - Memory Management Unit) หน่วยความจำขนาดเล็ก (RAM) หน่วยความจำแบบอ่านได้อย่างเดียว (ROM) ตัวบันทึกข้อมูลประเภทแฟลต เช่น MMC/SD Card เป็นต้น

  • Linux Kernel Layer (Kernel-space) - ทำหน้าที่ควบคุมจัดการอุปกรณ์ฮาร์ดแวร์ทั้งหมด จัดการการจัดคิวของโปรเซสต่างๆ จัดเตรียมฟังก์ชันสำคัญ (System Calls) ให้กับโปรแกรมประยุกต์ เป็นต้น ซึ่งจะมีองค์ประกอบภายในที่มีหน้าที่สำคัญๆ ได้แก่

    • Low-level interfaces

      • จัดเตรียมชุด APIs (Application Programming Interface) สำหรับการติดต่อกับฮาร์ดแวร์ แบบที่ไม่ขึ้นอยู่กับรุ่นของฮาร์ดแวร์

      • เป็นส่วนดูแลและจัดการฮาร์ดแวร์ต่างๆเช่น การทำงานของหน่วยประมวลผลกลาง การทำงานของหน่วยความจำ ติดต่อกับพอร์ตสื่อสาร และ I/O Devices เป็นต้น

    • High-level abstractions

      • จะจัดเตรียมฟังก์ชันให้โปรแกรมประยุกต์สามารถสื่อสารระหว่างกันได้ และทำงานแบบ multi-tasking ได้ เช่น IPC, Threading, Socket, Signalling เป็นต้น

      • โค้ดโปรแกรมส่วนใหญ่สามารถนำไปใช้ต่อได้เกือบทุกสถาปัตยกรรม

    • Filesystems

      • สามารถรองรับระบบ filesystems ต่างๆที่มีอยู่ในปัจจุบันได้ไม่น้อยกว่า 40 ชนิด

      • จะมี Virtual Filesystem layer ที่ทำให้การเรียกใช้ filesystems ที่แตกต่างเหล่านั้นง่ายและสะดวกขึ้นโดยที่ไม่ต้องเขียนโค้ดใหม่

    • Networking protocols

      • รองรับโปรโตคอลมาตราฐานต่างๆที่ใช้กันอยู่ในปัจจุบันได้ไม่น้อยกว่า 50 ชนิด

      • มีฟังก์ชัน Socket APIs ที่ใช้ในการจัดการและกำหนดการเชื่อมต่อในแต่ละแบบของระบบเครือข่ายนั้นๆ

  1. Libraries (User-space) - ไลบรารีที่อยู่ในระดับของ user space ที่มีความหลากหลายมากกว่าที่มีอยู่ในเคอร์เนล ไม่ว่าจะเป็นไลบรารีทางด้านการคำนวณ การแสดงผลกราฟฟิก การประมวลผลข้อมูลดิจิตอล การสื่อสารข้อมูลผ่านระบบเครือข่าย การเข้ารหัส/ถอดรหัส และ การติดต่อกับอุปกรณ์ฮาร์ดแวร์ที่มาเชื่อมต่อกับบอร์ด เป็นต้น ดังนั้นถ้าโปรแกรมประยุกต์ต้องการจะติดต่อกับเคอร์เนลจะเรียกผ่านไลบรารีชื่อว่า glibc (ซึ่งประกอบไปด้วยตัวย่อยคือ uClibc และ eglibc)

A history of shells

Shells หรือตัวแปลคำสั่ง มีประวัติอันยาวนาน แต่ในเนื้อหานี้เราจะเริ่มต้นด้วย shell แรกของ UNIX® ที่ Ken Thompson (จาก Bell Labs) พัฒนาขึ้นเรียกว่า V6 shell ในปี 1971 ซึ่งเหมือนกับลำดับก่อนหน้าใน Multics shell นี้ (/bin/sh) เป็นโปรแกรมผู้ใช้ที่เป็นอิสระที่ดำเนินการอยู่นอกเคอร์เนล แนวคิดเช่น Globbing เป็นเทคนิคที่ใช้ในการระบุหนึ่งหรือหลายไฟล์ด้วยแพทเทิร์น ส่วนใหญ่ใช้ในกรณีที่ผู้ใช้ไม่ต้องการหรือไม่สามารถระบุแต่ละไฟล์ได้โดยตรง สัญลักษณ์ที่ใช้ในการ globbing สามารถแตกต่างกันไปตามระบบปฏิบัติการ แต่ในระบบปฏิบัติการที่ใช้ Unix เช่น Linux หรือ macOS ประกอบด้วย:

  1. * (ดาว): ตรงกับศูนย์หรือมากกว่ารายการที่มีอยู่

  2. ? (เครื่องหมายคำถาม): ตรงกับตัวอักษรเดียว

  3. [] (สแควร์บราเก็ต): ตรงกับตัวอักษรใดตัวอักษรหนึ่งที่อยู่ในสแควร์บราเก็ต

ตัวอย่างการใช้ globbing:

  • *.txt: สั่งให้ระบบทำงานกับไฟล์ทั้งหมดที่มีนามสกุล .txt

  • data?: สั่งให้ระบบทำงานกับไฟล์ที่ชื่อขึ้นต้นด้วย "data" และตามด้วยตัวอักษรอื่นๆ ตัวเดียว

  • data[0-9]: สั่งให้ระบบทำงานกับไฟล์ที่ชื่อขึ้นต้นด้วย "data" และตามด้วยตัวเลข 0-9 อันใดอันหนึ่ง

การใช้ globbing ทำให้การจัดการไฟล์ต่างๆ ที่มีลักษณะที่คล้ายคลึงกันเป็นเรื่องง่ายขึ้นโดยสามารถระบุเป็นกลุ่ม ทำให้ไม่จำเป็นต้องระบุชื่อไฟล์ที่แน่นอนทุกครั้ง ทำให้การทำงานมีความรวดเร็วและมีประสิทธิภาพมากขึ้น โดยแนคิดนี้จึงถูก implement ในโปรแกรม utility ที่เรียกว่า glob เช่นเดียวกับคำสั่ง if สำหรับการประเมินนิพจน์เงื่อนไข การแยกส่วนนี้ทำให้ shell มีขนาดเล็ก ที่เขียนด้วยภาษา C ต่ำกว่า 900 บรรทัด

Shell นำเสนอไวยากรณ์ที่สั้นกระชับสำหรับการเปลี่ยนทาง (< > และ >>) และการท่อ (| หรือ ^) ที่ยังคงมีอยู่ใน shell สมัยใหม่ คุณยังพบการสนับสนุนการเรียกใช้คำสั่งที่ต่อเนื่อง (ด้วย ;) และคำสั่งที่ไม่ประสานกัน (ด้วย &)

สิ่งที่ขาดหายไปใน shell ของ Thompson คือความสามารถในการเขียนสคริปต์ จุดประสงค์เดียวของมันคือเป็น shell แบบโต้ตอบ (ตัวแปลคำสั่ง) เพื่อเรียกใช้คำสั่งและดูผลลัพธ์

ตั้งแต่ที่ Thompson Shell เกิดขึ้น แต่คนก็พยายามหา shell ยุคสมัยใหม่อย่าง Bourne shell ที่เกิดขึ้นใน คศ. 1977 ซึ่งถูกสร้างโดย Stephen Bourne ที่ AT&T Bell Labs สำหรับ V7 UNIX และยังเป็น shell ที่มีประโยชน์ในปัจจุบัน (บางกลุ่มเรียกว่า root shell) ไวยากรณ์ (syntax) ของ Bourne shell จะมีความคล้ายคลึงกับ Algorithmic Language (ALGOL) มากกว่า shell อื่น ๆ

Bourne shell มีสองเป้าหมายหลักคือทำหน้าที่เป็นตัวแปลคำสั่งเพื่อใช้ในการเรียกใช้คำสั่งของระบบปฏิบัติการแบบโต้ตอบและสำหรับสคริปต์ (เขียนสคริปต์ที่สามารถใช้ซ้ำและเรียกใช้ผ่าน shell) นอกจากการแทนที่ shell ของ Thompson แล้ว Bourne shell ยังมีหลายข้อดีเหนือตัวอื่น ๆ โดยได้นำเสนอ control flows, loops, และ variables ลงในสคริปต์ ให้ภาษามีประสิทธิภาพมากขึ้นในการโต้ตอบกับระบบปฏิบัติการได้

Basic Shell Architecture

สถาปัตยกรรมพื้นฐานของ hypothetical shell นั้นเรียบง่าย (ตามที่แสดงให้เห็นโดย shell ของ Bourne ในรูปข้างล่าง) โดยสถาปัตยกรรมพื้นฐานดูคล้ายกับ pipeline ที่ทำการวิเคราะห์และแยกส่วนข้อมูลที่ป้อนเข้ามา, สัญลักษณ์ (symbols) จะนำมาถูกขยายความ (เช่น การขยายและการแทนที่ brace, tilde, variable และ parameter, และการสร้างชื่อไฟล์) และในที่สุดคำสั่งจะถูกดำเนินการ (โดยใช้คำสั่งที่ต่อติดใน shell, หรือคำสั่งภายนอก)

🖥️
อ่านรายละเอียดของ Linux Kernel เพิ่มเติม
เริ่มปล่อย kernel source codes ตั้งแต่นั้นมา
จำนวนบรรทัดของ source codes ของ major Linux kernel ในแต่ละ release
โครงสร้างแต่ละชั้นของระบบปฏิบัติการลีนุกซ์
สถาปัตยกรรมภายในระบบปฏิบัติการลีนุกซ์
Linux shells ตั้งแต่ ปี คศ. 1977
สถาปัตยกรรมอย่างง่ายของ hypothetical shell