Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
os-project3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Damin Lee
os-project3
Commits
320ccfda
Commit
320ccfda
authored
5 years ago
by
dnflekals
Browse files
Options
Downloads
Patches
Plain Diff
revise ringbuffer
parent
8e9b5782
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lock
+0
-0
0 additions, 0 deletions
lock
pa3.c
+2
-4
2 additions, 4 deletions
pa3.c
with
2 additions
and
4 deletions
lock
+
0
−
0
View file @
320ccfda
No preview for this file type
This diff is collapsed.
Click to expand it.
pa3.c
+
2
−
4
View file @
320ccfda
...
@@ -204,8 +204,7 @@ struct mutex full;
...
@@ -204,8 +204,7 @@ struct mutex full;
void
enqueue_into_ringbuffer
(
int
value
){
void
enqueue_into_ringbuffer
(
int
value
){
acquire_mutex
(
&
full
);
acquire_mutex
(
&
full
);
acquire_mutex
(
&
mutexs
);
acquire_mutex
(
&
mutexs
);
ringbuffer
.
slots
[
ringbuffer
.
in
]
=
value
;
ringbuffer
.
slots
[(
ringbuffer
.
in
++
)
%
ringbuffer
.
nr_slots
]
=
value
;
ringbuffer
.
in
=
(
ringbuffer
.
in
+
1
)
%
ringbuffer
.
nr_slots
;
release_mutex
(
&
mutexs
);
release_mutex
(
&
mutexs
);
release_mutex
(
&
empty
);
release_mutex
(
&
empty
);
}
}
...
@@ -224,8 +223,7 @@ int dequeue_from_ringbuffer(void)
...
@@ -224,8 +223,7 @@ int dequeue_from_ringbuffer(void)
{
{
acquire_mutex
(
&
empty
);
acquire_mutex
(
&
empty
);
acquire_mutex
(
&
mutexs
);
acquire_mutex
(
&
mutexs
);
int
data
=
ringbuffer
.
slots
[
ringbuffer
.
out
];
int
data
=
ringbuffer
.
slots
[(
ringbuffer
.
out
++
)
%
ringbuffer
.
nr_slots
];
ringbuffer
.
out
=
(
ringbuffer
.
out
+
1
)
%
ringbuffer
.
nr_slots
;
release_mutex
(
&
mutexs
);
release_mutex
(
&
mutexs
);
release_mutex
(
&
full
);
release_mutex
(
&
full
);
return
data
;
return
data
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment