-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Posix implementation layer #5667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nashif
merged 14 commits into
zephyrproject-rtos:master
from
youvedeep:Posix_Implementation_Layer
Feb 22, 2018
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3f10d3d
kernel: POSIX: Fixing return value of POSIX APIs on error.
youvedeep-singh c29dd0d
kernel: POSIX: moving POSIX related typedef into sys/types.h file.
youvedeep-singh 7f17666
kernel: POSIX: Compatibility layer for pthread APIs.
youvedeep-singh 9f7747d
kernel: POSIX: Compatibility layer for scheduler APIs.
youvedeep-singh 89e9f09
kernel: POSIX: Compatibility layer for POSIX sleep APIs.
youvedeep-singh b845895
kernel: POSIX: Compatibility layer for POSIX clock APIs.
youvedeep-singh 347fc61
kernel: POSIX: removing unused elements from POSIX object attribute.
youvedeep-singh 2261f14
tests: kernel: posix: pthread_join: Add pthread join test.
youvedeep-singh 7181b09
tests: kernel: posix: clock: Add posix clock test.
youvedeep-singh cef171e
tests: kernel: posix: pthread: Add pthread test.
youvedeep-singh da5609c
tests: kernel: posix: pthread_cancel: POSIX thread cancel test.
youvedeep-singh 4d8bad8
kernel: POSIX: Compatibility layer for POSIX timer APIs.
youvedeep-singh a4d00b5
tests: kernel: posix: timer: POSIX timer test.
youvedeep-singh 9ae6024
arch: POSIX: Add guard into posix_cheats file.
youvedeep-singh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2018 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef __POSIX_SCHED_H__ | ||
#define __POSIX_SCHED_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Cooperative scheduling policy */ | ||
#ifndef SCHED_FIFO | ||
#define SCHED_FIFO 0 | ||
#endif /* SCHED_FIFO */ | ||
|
||
/* Priority based preemptive scheduling policy */ | ||
#ifndef SCHED_RR | ||
#define SCHED_RR 1 | ||
#endif /* SCHED_RR */ | ||
|
||
struct sched_param { | ||
int priority; | ||
}; | ||
|
||
/** | ||
* @brief Yield the processor | ||
* | ||
* See IEEE 1003.1 | ||
*/ | ||
static inline int sched_yield(void) | ||
{ | ||
k_yield(); | ||
return 0; | ||
} | ||
|
||
int sched_get_priority_min(int policy); | ||
int sched_get_priority_max(int policy); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __POSIX_SCHED_H__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2018 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef __POSIX_SIGNAL_H__ | ||
#define __POSIX_SIGNAL_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "sys/types.h" | ||
|
||
#ifndef SIGEV_NONE | ||
#define SIGEV_NONE 1 | ||
#endif | ||
|
||
#ifndef SIGEV_SIGNAL | ||
#define SIGEV_SIGNAL 2 | ||
#endif | ||
|
||
#ifndef SIGEV_THREAD | ||
#define SIGEV_THREAD 3 | ||
#endif | ||
|
||
typedef union sigval { | ||
int sival_int; | ||
void *sival_ptr; | ||
} sigval; | ||
|
||
typedef struct sigevent { | ||
int sigev_notify; | ||
int sigev_signo; | ||
sigval sigev_value; | ||
void (*sigev_notify_function)(sigval val); | ||
pthread_attr_t *sigev_notify_attributes; | ||
} sigevent; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __POSIX_TIME_H__ */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have a semaphore and a pthread_mutex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pthread_mutex_t just contains a pointer to a semphore.
So we need a semaphore to for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user using these APIs will have to define a k_sem as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pthread mutex was implemented by @andyross in last zephyr release.
As per my understanding, there are 2 ways to achieve this :-
I think we need to modify this later, as it does not seem intuitive to a app developer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make it work for both cases (by statically initializing it with that macro or calling pthread_init()) if pthread_mutex_t were embedding a k_sem rather than pointing to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to fix this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @andrewboie we need to fix this now. But it will need changes in almost all mutex related APIs. At this stage I am avoiding this because merge window is approaching and this will gate all POSIX patches. I will put a FIXME: Comment here and will take this up after 1.11.