A giant lock is a solitary global lock that is held whenever a thread enters kernel space and released when the thread returns to user space; a system call is the archetypal example. In this model, threads in user space can run concurrently on any available processors or processor cores, but no more than one thread can run in kernel space; any other threads that try to enter kernel space are forced to wait. In other words, the giant lock eliminates all concurrency in kernel space.
By isolating the kernel from concurrency, many parts of the kernel no longer need to be modified to support SMP. However, as in giant-lock SMP systems only one processor can run the kernel code at a time, performance for applications spending significant amounts of time in the kernel is not much improved.[1] Accordingly, the giant-lock approach is commonly seen as a preliminary means of bringing SMP support to an operating system, yielding benefits only in user space. Most modern operating systems use a fine-grained locking approach.
As of September2022[update], Linux kernel still has console_lock and rtnl_lock, which are sometimes referred as BKL, and its removal is in progress.[4][5][6][7]
BSD
As of July2019[update], OpenBSD and NetBSD are still using the spl family of primitives to facilitate synchronisation of critical sections within the kernel,[8][9][10] meaning that many system calls may inhibit SMP capabilities of the system, and, according to Matthew Dillon, the SMP capabilities of these two systems cannot be considered modern.[11]
FreeBSD still has support for the Giant mutex,[12] which provides semantics akin to the old spl interface, but performance-critical core components have long been converted to use finer-grained locking.[1]
The NetBSD Foundation views modern SMP support as vital to the direction of The NetBSD Project, and has offered grants to developers willing to work on SMP improvements; NPF (firewall) was one of the projects that arose as a result of these financial incentives, but further improvements to the core networking stack may still be necessary.[9][13]
↑Julian Elischer (2007). "locking(9) — kernel synchronization primitives". BSD Cross Reference. FreeBSD. Retrieved 2019-07-25. Giant is a special mutex used to protect data structures that do not yet have their own locks. Since it provides semantics akin to the old spl(9) interface, …