Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Meeting Summary for CS 326 Lecture/Lab Spring 2025

Date: May 08, 2025
Time: 02:52 PM Pacific Time (US and Canada)
Meeting ID: 813 3845 7711


Quick Recap

During the session, Greg highlighted several important topics:

  • The significance of containers in modern technology, their practical uses, and cloud deployment.
  • Fundamental concepts including processes, containers, virtual machines, and emulation.
  • A system call implementation designed to check if a given address is mapped in the current process’s virtual address space.
  • Discussions regarding code pages and the role of guard pages in protecting user memory.

Next Steps

Students are expected to complete the following actions:

  • Review Practice Problems: Study the practice problems and solutions in preparation for the final exam.
  • Prepare Final Exam Notes: Create two pages of notes (front and back) for the final exam.
  • Complete Teaching Effectiveness Survey: Fill out the survey if it has not already been completed.
  • Timely Start of Final Exam: Ensure that the final exam begins punctually as scheduled by Greg.

Detailed Topics

Container Technology and Cloud Deployment

Greg discussed the pivotal role of containers in current technology. Key points included:

  • Containers vs. Traditional Systems:
    • Containers isolate collections of processes.
    • They can encapsulate complex software with kernel support enabling efficient operation.
  • Deployment Examples:
    • Demonstrated container creation and execution using Docker.
    • Described local deployment as well as cloud deployments on services like Google Cloud and AWS.
    • Noted the cost considerations when deploying containers in the cloud.

Container Deployment Diagram

Below is a Mermaid diagram illustrating the container deployment process:

flowchart TD
    A[Develop Container Image<br>e.g., Dockerfile]
    B[Build Image Locally]
    C[Test Container Locally]
    D[Deploy to Cloud Service<br>Google/AWS]
    E[Run Container in<br>Production Environment]
    
    A --> B
    B --> C
    C --> D
    D --> E

Container and Virtual Machine Technologies

The session covered various isolation technologies, comparing their characteristics:

  • Processes:
    Provide isolation at the level of individual tasks.

  • Containers:
    Offer isolation for groups of processes within a single operating system instance.

  • Virtual Machines (VMs):
    Run entire operating systems; they demand similar architecture as the host and are generally heavier than containers.

  • Emulation:
    Although slower, emulation is often used for specialized debugging and to develop new processor architectures.

Technology Comparison Diagram

The following Mermaid diagram summarizes the relationship between these technologies:

flowchart LR
    subgraph Isolation Techniques
      P[Process Isolation]
      C[Container Isolation<br>Multiple Processes]
      VM[Virtual Machine Isolation<br>Full OS]
      E[Emulation<br>Emulated CPU]
    end

    P --> C
    C --> VM
    VM --> E

Kernel Allocator and System Call Implementation

Greg explained aspects of project 2 related to kernel programming:

  • Kernel Allocator & Pipes:
    Explored the kernel allocator and pipe implementation.

  • Transferring Data:
    Illustrated how to write memory from the kernel into a user process’s address space using the UVM copy mechanism.

  • Process Status System Call:
    Covered how the process table is printed from within the kernel via a system call.

  • System Call Execution Flow:
    Detailed the execution path starting with the user application making the system call, passing through the trap into the kernel, executing the system call function, and finally storing the result in the trap frame.

System Call Flow Diagram

flowchart TD
    A[User Process calls system call]
    B[C Library Wrapper adds system call number]
    C[Trap into Kernel]
    D[Kernel Dispatches to System Call Function]
    E[System Call Execution]
    F[Store Return Value in Trap Frame]
    G[Return Control to User Process]
    
    A --> B
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G

Exploring System Call Implementation

Greg also introduced a discussion on how to design new system calls:

  • Hypothetical System Call:
    A proposal was made for a system call to check whether a file descriptor is open.

  • Design Considerations:
    The discussion encouraged considering the style of upcoming projects with an emphasis on both understanding core concepts and providing code.

Example: xv6-riscv System Call for Mapping Check

Below is a simplified xv6-riscv C code snippet that demonstrates a system call to check if an address is mapped in a process’s virtual address space:

#include "types.h"
#include "riscv.h"
#include "defs.h"

// System call: Check if address is mapped
uint64
sys_ismapped(void)
{
  uint64 addr;
  // Retrieve the first argument (address) passed by the user.
  if(argaddr(0, &addr) < 0)
    return -1;

  struct proc *p = myproc();
  // Walk the page table without creating new entries.
  pte_t *pte = walk(p->pagetable, addr, 0);

  // Check if the page table entry exists and if the valid bit is set.
  if(pte && (*pte & PTE_V))
    return 1;  // Address is mapped.
  
  return 0;    // Address is not mapped.
}

Root Code Containers and Teaching Survey

Additional topics discussed included:

  • Root Code Containers:
    Discussion about implementing root code containers and managing system-level code separation.

  • Teaching Effectiveness Survey:
    A reminder was issued regarding the importance of submitting the teaching effectiveness survey to help improve the course.

  • Hypothetical Scenarios:
    Greg posed questions about system calls related to file descriptor table management, encouraging creative thinking around system design.


Checking Address Mapping in a Virtual Address Space

A significant portion of the meeting was devoted to the implementation details of a system call that checks memory mapping:

  • Functionality:
    The system call returns true (1) if a specified address is mapped and false (0) otherwise.

  • Implementation Details:

    • Walk the process’s page table to locate the Page Table Entry (PTE).
    • Verify that the PTE is valid; i.e., it is non-zero and has the valid bit set.
    • Optionally, check that user and read permissions are set to confirm accessibility.

Code Pages and Guard Pages

Finally, Greg emphasized the importance of understanding code pages and their protection mechanisms:

  • Code Pages:
    These pages store executable code and have distinct properties compared to data pages.

  • Guard Pages:
    Special pages designed to prevent accidental user access and to provide memory protection.

  • Study Recommendations:
    Students were encouraged to thoroughly review the provided code and problem solutions to reinforce their understanding of the material.


Conclusion

The session provided a comprehensive overview of container technology, virtualization, system call implementation, and memory management techniques. Students are advised to revisit these topics through notes, practice problems, and the provided code examples to solidify their understanding ahead of the final exam.