西维蜀黍

【macOS】制作macOS Big Sur Beta 镜像

对于 Big Sur,目前只能在一个已经安装了macOS的OS上制作macOS镜像。

Download from macOS

Before you can install the new operating system, you must be enrolled in the Public Beta program. You can do this through Apple’s Public Beta program website. In the Get Started section of the website, click on the “enroll your Mac” link.

This should take you to the “Enroll you devices” webpage. Follow the instructions. In step 2, you will download the “macOS Public Beta Access Utility” which will enroll your Mac into the program. Then the utility will launch Software Update to download and install the Big Sur beta.

https://www.macworld.com/article/234359/how-to-install-the-macos-11-big-sur-public-beta.html

Then insatll macOS Big Sur Beta via System Update

Once finish, you would have this:

  ...


【Hackintosh】更新与维护

常用工具

  • hackintool
  • IORegistryExplorer
  • OpenCore Configurator

OS Setting

Issues

Power Management

Fixing Sleep

https://forum.amd-osx.com/index.php?threads/audiogods-gigabyte-aorus-x570-pro-pro-wifi-ultra-master-big-sur-opencore-0-7-1-efi.1344/post-10975

https://forum.amd-osx.com/index.php?resources/usbtoolbox.12/

选择系统icon更大

NVRAM - UIScale 设置为01

Debug

-boot-args 中加入 -v

boot-args

Here we get to set some variables that will help us with debug output, for us we’ll be using the following boot-args:

-v keepsyms=1 debug=0x12a msgbuf=1048576

踩坑

  • 如果在安装系统的时候,加了上面这些参数,可能会导致无限重启而无法进入安装系统界面,因此在安装系统时,仍然可以使用上面参数进行debug,但是如果发生无限重启时,需要把送上面参数去掉

Now lets go over what each arg does:

  • -v
    • Enables verbose output
  • keepsyms=1
    • Ensures symbols are kept during kernel panics, which are greatly helpful for troubleshooting
  • debug=0x12a
    • Combination of DB_PRT (0x2), DB_KPRT (0x8), DB_SLOG (0x20), and DB_LOG_PI_SCRN (0x100)
    • A full list of values for the latest version of XNU can be found here: debug.h(opens new window)
  • msgbuf=1048576
    • Sets the kernel’s message buffer size, this helps with getting proper logs during boot
    • 1048576 is 1MB(/1024^2), can be larger if required
    • Note not required with DebugEnhancer.kext, however for early kernel logs it’s still required

Ref

Update

Refer to https://dortania.github.io/OpenCore-Post-Install/universal/update.html#updating-opencore-and-macos

Update OpenCore

Note

  • So first, lets mount your hard drive’s EFI and make a copy somewhere safe with MountEFI (opens new window). We won’t be updating the drive’s EFI at first, instead we’ll be grabbing a spare USB to be our crash dummy. This allows us to keep a working copy of OpenCore in case our update goes south

  • For the USB, it must be formatted as GUID. Reason for this is that GUID will automatically create an EFI partition, though this will be hidden by default so you’ll need to mount it with MountEFI.

  • partition, though this will be hidden by default so you’ll need to mount it with MountEFI.

Now you can place your OpenCore EFI on the USB

Replace the OpenCore files with the ones you just downloaded

  • The important ones to update:
    • EFI/BOOT/BOOTx64.efi
    • EFI/OC/OpenCore.efi
    • EFI/OC/Drivers/OpenRuntime(Don’t forget this one, OpenCore will not boot with mismatched versions)
  • You can also update other drivers you have if present, these are just the ones that must be updated in order to boot correctly

Refer to https://dortania.github.io/OpenCore-Post-Install/universal/update.html#updating-opencore

Validate Config.plist

  • Use the OpenCore Utility ocvalidate: this tool will help ensure your config.plist is matching the OpenCore specification of the matching build.
# Enter your OpenCore folder
$ cd /Users/shiwei/Downloads/OpenCore-0.6.9-RELEASE
$ ./Utilities/ocvalidate/ocvalidate /Users/shiwei/Downloads/MyOpenCoreConfig/EFI/OC/Config.plist
  ...


【Golang】使用 - sync.RWMutex

package main

import (
	"sync"
)

// SafeCounter is safe to use concurrently.
type SafeCounter struct {
	mu sync.RWMutex
	v  map[string]int
}

// Inc increments the counter for the given key.
func (c *SafeCounter) Write(key string) {
	c.mu.Lock()
	// Lock so only one goroutine at a time can access the map c.v.
	c.v[key]++
	c.mu.Unlock()
}

// Value returns the current value of the counter for the given key.
func (c *SafeCounter) Read(key string) int {
	c.mu.RLock()
	defer c.mu.RUnlock()
	return c.v[key]
}

func main() {
	c := SafeCounter{v: make(map[string]int)}
	go func() {
		for {
			_ = c.Read("test")
		}
	}()
	go func() {
		for {
			c.Write("test")
		}
	}()
	select {}
}
  ...


【Design Pattern】Concurrency - Read Write Lock Pattern

Readers–writer Lock

In computer science, a readers–writer (single-writer lock, a multi-reader lock, a push lock, or an MRSW lock) is a synchronization primitive that solves one of the readers–writers problems.

An RW lock allows concurrent access for read-only operations, while write operations require exclusive access.

This means that multiple threads can read the data in parallel but an exclusive lock is needed for writing or modifying data. When a writer is writing the data, all other writers or readers will be blocked until the writer is finished writing. A common use might be to control access to a data structure in memory that cannot be updated atomically and is invalid (and should not be read by another thread) until the update is complete.

Readers–writer locks are usually constructed on top of mutexes and condition variables, or on top of semaphores.

  ...


【Golang】源码 - sync包 - Pool

sync.Pool

A Pool is a set of temporary objects that may be individually saved and retrieved.

Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated.

A Pool is safe for use by multiple goroutines simultaneously.

Pool’s purpose is to cache allocated but unused items for later reuse, relieving pressure on the garbage collector. That is, it makes it easy to build efficient, thread-safe free lists. However, it is not suitable for all free lists.

An appropriate use of a Pool is to manage a group of temporary items silently shared among and potentially reused by concurrent independent clients of a package. Pool provides a way to amortize allocation overhead across many clients.

  ...