MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _vm_map_lock_upgrade

Function _vm_map_lock_upgrade

freebsd/vm/vm_map.c:768–793  ·  view source on GitHub ↗

* _vm_map_lock_upgrade: [ internal use only ] * * Tries to upgrade a read (shared) lock on the specified map to a write * (exclusive) lock. Returns the value "0" if the upgrade succeeds and a * non-zero value if the upgrade fails. If the upgrade fails, the map is * returned without a read or write lock held. * * Requires that the map be read locked. */

Source from the content-addressed store, hash-verified

766 * Requires that the map be read locked.
767 */
768int
769_vm_map_lock_upgrade(vm_map_t map, const char *file, int line)
770{
771 unsigned int last_timestamp;
772
773 if (map->system_map) {
774 mtx_assert_(&map->system_mtx, MA_OWNED, file, line);
775 } else {
776 if (!sx_try_upgrade_(&map->lock, file, line)) {
777 last_timestamp = map->timestamp;
778 sx_sunlock_(&map->lock, file, line);
779 vm_map_process_deferred();
780 /*
781 * If the map's timestamp does not change while the
782 * map is unlocked, then the upgrade succeeds.
783 */
784 sx_xlock_(&map->lock, file, line);
785 if (last_timestamp != map->timestamp) {
786 sx_xunlock_(&map->lock, file, line);
787 return (1);
788 }
789 }
790 }
791 map->timestamp++;
792 return (0);
793}
794
795void
796_vm_map_lock_downgrade(vm_map_t map, const char *file, int line)

Callers

nothing calls this directly

Calls 2

vm_map_process_deferredFunction · 0.85
sx_try_upgrade_Function · 0.50

Tested by

no test coverage detected