From 295a5c3f8bd9dbdd22fe798d927d557c474a7569 Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Wed, 18 Jan 2023 01:04:41 +0000 Subject: [PATCH] Define a parallel queue for lock operations Fixes #74 --- index.bs | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/index.bs b/index.bs index 737bc5b..7f94682 100644 --- a/index.bs +++ b/index.bs @@ -94,24 +94,29 @@ A file entry additionally consists of a lock (a string that may exclusively be "`open`", "`taken-exclusive`" or "`taken-shared`") and a shared lock count (a number representing the number shared locks that are taken at a given point in time). +The file system lock queue is a +[=parallel queue=] to be used for all tasks involving a +[=file entry/lock=]. +
To take a [=file entry/lock=] with a |value| of "`exclusive`" or "`shared`" on a given [=file entry=] |file|: 1. Let |lock| be the |file|'s [=file entry/lock=]. -1. Let |count| be the |file|'s [=file entry/shared lock count=]. -1. If |value| is "`exclusive`": - 1. If |lock| is "`open`": - 1. Set lock to "`taken-exclusive`". - 1. Return true. -1. If |value| is "`shared`": - 1. If |lock| is "`open`": - 1. Set |lock| to "`taken-shared`". - 1. Set |count| to 1. - 1. Return true. - 1. Otherwise, if |lock| is "`taken-shared`": - 1. Increase |count| by one. - 1. Return true. -1. Return false. +1. [=Enqueue the following steps=] to the [=file system lock queue=]: + 1. Let |count| be the |file|'s [=file entry/shared lock count=]. + 1. If |value| is "`exclusive`": + 1. If |lock| is "`open`": + 1. Set lock to "`taken-exclusive`". + 1. Return true. + 1. If |value| is "`shared`": + 1. If |lock| is "`open`": + 1. Set |lock| to "`taken-shared`". + 1. Set |count| to 1. + 1. Return true. + 1. Otherwise, if |lock| is "`taken-shared`": + 1. Increase |count| by one. + 1. Return true. + 1. Return false.
@@ -120,11 +125,12 @@ To release a [=file entry/lock=] on a given [=f run these steps: 1. Let |lock| be the |file|'s associated [=file entry/lock=]. -1. Let |count| be the |file|'s [=file entry/shared lock count=]. -1. If |lock| is "`taken-shared`": - 1. Decrease |count| by one. - 1. If |count| is 0, set |lock| to "`open`". -1. Otherwise, set |lock| to "`open`". +1. [=Enqueue the following steps=] to the [=file system lock queue=]: + 1. Let |count| be the |file|'s [=file entry/shared lock count=]. + 1. If |lock| is "`taken-shared`": + 1. Decrease |count| by one. + 1. If |count| is 0, set |lock| to "`open`". + 1. Otherwise, set |lock| to "`open`".