Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5b28ee5a
authored
Nov 30, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
process queue structure
parent
9a970ebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
src/queue.c
src/queue.h
src/queue.c
0 → 100644
View file @
5b28ee5a
#include "queue.h"
#define NULL 0
struct
node
{
process
*
proc
;
struct
node
*
next
;
};
struct
node
*
node_create
(
process
*
proc
)
{
struct
node
*
n
=
malloc
(
sizeof
(
struct
node
));
n
->
next
=
NULL
;
n
->
proc
=
proc
;
return
n
;
}
void
queue_push
(
queue
q
,
process
*
proc
)
{
struct
node
*
n
=
node_create
(
proc
);
if
(
q
.
rear
!=
NULL
)
{
q
.
rear
->
next
=
n
;
q
.
rear
=
n
;
}
else
{
q
.
rear
=
q
.
front
=
n
;
}
}
void
queue_pop
(
queue
q
)
{
if
(
q
.
front
!=
NULL
)
{
struct
node
*
f
=
q
.
front
->
next
;
//free(q.front)
q
.
front
=
f
;
if
(
q
.
front
==
NULL
)
{
q
.
rear
=
NULL
;
}
}
}
process
*
queue_front
(
queue
q
)
{
return
q
.
front
->
proc
;
}
void
create
(
queue
q
)
{
q
.
front
=
q
.
rear
=
NULL
;
}
src/queue.h
0 → 100644
View file @
5b28ee5a
#ifndef _QUEUE_INC
#define _QUEUE_INC
#include "PCB.h"
struct
node
;
typedef
struct
{
struct
node
*
front
,
*
rear
;
}
queue
;
void
queue_push
(
queue
q
,
process
*
proc
);
void
queue_pop
(
queue
q
);
process
*
queue_front
(
queue
q
);
void
create
(
queue
q
);
#endif
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