Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9540d978
Commit
9540d978
authored
Feb 19, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIFO lock wait queue, with readers grouped together.
parent
9a550134
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
+34
-12
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+34
-12
No files found.
src/backend/storage/lmgr/proc.c
View file @
9540d978
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.3
0 1998/01/28 02:29:29
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.3
1 1998/02/19 15:04:45
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
* This is so that we can support more backends. (system-wide semaphore
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
* sets run out pretty fast.) -ay 4/95
*
*
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.3
0 1998/01/28 02:29:29
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.3
1 1998/02/19 15:04:45
momjian Exp $
*/
*/
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -451,19 +451,42 @@ ProcSleep(PROC_QUEUE *waitQueue,
...
@@ -451,19 +451,42 @@ ProcSleep(PROC_QUEUE *waitQueue,
int
prio
,
int
prio
,
LOCK
*
lock
)
LOCK
*
lock
)
{
{
int
i
;
int
i
=
0
;
PROC
*
proc
;
PROC
*
proc
;
struct
itimerval
timeval
,
struct
itimerval
timeval
,
dummy
;
dummy
;
/*
* If the first entries in the waitQueue have a greater priority than
* we have, we must be a reader, and they must be a writers, and we
* must be here because the current holder is a writer or a
* reader but we don't share shared locks if a writer is waiting.
* We put ourselves after the writers. This way, we have a FIFO, but
* keep the readers together to give them decent priority, and no one
* starves. Because we group all readers together, a non-empty queue
* only has a few possible configurations:
*
* [readers]
* [writers]
* [readers][writers]
* [writers][readers]
* [writers][readers][writers]
*
* In a full queue, we would have a reader holding a lock, then a
* writer gets the lock, then a bunch of readers, made up of readers
* who could not share the first readlock because a writer was waiting,
* and new readers arriving while the writer had the lock.
*
*/
proc
=
(
PROC
*
)
MAKE_PTR
(
waitQueue
->
links
.
prev
);
proc
=
(
PROC
*
)
MAKE_PTR
(
waitQueue
->
links
.
prev
);
for
(
i
=
0
;
i
<
waitQueue
->
size
;
i
++
)
{
/* If we are a reader, and they are writers, skip past them */
if
(
proc
->
prio
>=
prio
)
while
(
i
++
<
waitQueue
->
size
&&
proc
->
prio
>
prio
)
proc
=
(
PROC
*
)
MAKE_PTR
(
proc
->
links
.
prev
);
proc
=
(
PROC
*
)
MAKE_PTR
(
proc
->
links
.
prev
);
else
break
;
/* The rest of the queue is FIFO, with readers first, writers last */
}
while
(
i
++
<
waitQueue
->
size
&&
proc
->
prio
<=
prio
)
proc
=
(
PROC
*
)
MAKE_PTR
(
proc
->
links
.
prev
);
MyProc
->
prio
=
prio
;
MyProc
->
prio
=
prio
;
MyProc
->
token
=
token
;
MyProc
->
token
=
token
;
...
@@ -596,8 +619,7 @@ ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock)
...
@@ -596,8 +619,7 @@ ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock)
/*
/*
* ProcWakeup removes proc from the lock waiting process queue and
* ProcWakeup removes proc from the lock waiting process queue and
* returns the next proc in chain. If a writer just dropped its
* returns the next proc in chain.
* lock and there are several waiting readers, wake them all up.
*/
*/
proc
=
ProcWakeup
(
proc
,
NO_ERROR
);
proc
=
ProcWakeup
(
proc
,
NO_ERROR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment