修正打印顺序错乱问题
This commit is contained in:
@@ -23,8 +23,12 @@
|
||||
#include <u_path.h>
|
||||
#include "kstat.h"
|
||||
#include "svr_path.h"
|
||||
#include "u_mutex.h"
|
||||
#include "u_hd_man.h"
|
||||
#define FS_PATH_LEN 64
|
||||
static char cur_path[FS_PATH_LEN] = "/";
|
||||
|
||||
static u_mutex_t lock_cons;
|
||||
// AUTO_CALL(101)
|
||||
void fs_backend_init(void)
|
||||
{
|
||||
@@ -46,6 +50,7 @@ void fs_backend_init(void)
|
||||
assert(fd_map_alloc(0, 0, FD_TTY) >= 0);
|
||||
assert(fd_map_alloc(0, 1, FD_TTY) >= 0);
|
||||
assert(fd_map_alloc(0, 2, FD_TTY) >= 0);
|
||||
assert(u_mutex_init(&lock_cons, handler_alloc()) >= 0);
|
||||
}
|
||||
pwd = getenv("PWD");
|
||||
if (pwd)
|
||||
@@ -53,7 +58,12 @@ void fs_backend_init(void)
|
||||
be_chdir(pwd);
|
||||
}
|
||||
}
|
||||
|
||||
void fs_cons_write(void *buf, size_t size)
|
||||
{
|
||||
u_mutex_lock(&lock_cons, 0, NULL);
|
||||
ulog_write_bytes(u_get_global_env()->log_hd, buf, size);
|
||||
u_mutex_unlock(&lock_cons);
|
||||
}
|
||||
int be_open(const char *path, int flags, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
@@ -178,13 +188,7 @@ long be_read(long fd, char *buf, long size)
|
||||
switch (u_fd.type)
|
||||
{
|
||||
case FD_TTY:
|
||||
{
|
||||
#if 0
|
||||
return be_tty_read(buf, size);
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case FD_FS:
|
||||
{
|
||||
@@ -215,7 +219,7 @@ long be_write(long fd, char *buf, long size)
|
||||
task_get_pid(TASK_THIS, (umword_t *)(&pid));
|
||||
if (pid == 0)
|
||||
{
|
||||
ulog_write_bytes(u_get_global_env()->log_hd, buf, size);
|
||||
fs_cons_write(buf, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -314,7 +318,7 @@ long be_writev(long fd, const struct iovec *iov, long iovcnt)
|
||||
task_get_pid(TASK_THIS, (umword_t *)(&pid));
|
||||
if (pid == 0)
|
||||
{
|
||||
ulog_write_bytes(u_get_global_env()->log_hd, iov[i].iov_base, iov[i].iov_len);
|
||||
fs_cons_write(iov[i].iov_base, iov[i].iov_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ static fs_t tty_fs;
|
||||
|
||||
static int tty_def_line_handler(tty_struct_t *tty, uint8_t r);
|
||||
static int tty_write_hw(tty_struct_t *tty);
|
||||
void tty_write_data(void *buf, size_t len);
|
||||
|
||||
void tty_set_fg_pid(pid_t pid)
|
||||
{
|
||||
@@ -123,7 +124,7 @@ static int cons_init(void)
|
||||
msg_tag_t tag;
|
||||
|
||||
u_mutex_init(&sys_tty.lock_cons, handler_alloc());
|
||||
u_mutex_init(&sys_tty.lock_write_cons, handler_alloc());
|
||||
// u_mutex_init(&sys_tty.lock_write_cons, handler_alloc());
|
||||
|
||||
sem_th = handler_alloc();
|
||||
if (sem_th == HANDLER_INVALID)
|
||||
@@ -145,7 +146,7 @@ static int tty_open(const char *path, int flags, int mode)
|
||||
{
|
||||
|
||||
ulog_write_str(LOG_PROT, "tty open..\n");
|
||||
sys_tty.fd_flags = flags;
|
||||
sys_tty.fd_flags = flags;//FIXME:修正支持不同fd拥有不同的flags。
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -458,7 +459,7 @@ static int tty_write_hw(tty_struct_t *tty)
|
||||
}
|
||||
while ((res = q_dequeue(&tty->w_queue, &r)) >= 0)
|
||||
{
|
||||
ulog_write_bytes(LOG_PROT, &r, 1);
|
||||
tty_write_data(&r, 1);
|
||||
w_len++;
|
||||
}
|
||||
return w_len;
|
||||
@@ -505,9 +506,8 @@ again:
|
||||
}
|
||||
void tty_write_data(void *buf, size_t len)
|
||||
{
|
||||
u_mutex_lock(&sys_tty.lock_write_cons, 0, 0);
|
||||
ulog_write_bytes(LOG_PROT, buf, len);
|
||||
u_mutex_unlock(&sys_tty.lock_write_cons);
|
||||
extern void fs_cons_write(void *buf, size_t size);
|
||||
fs_cons_write(buf, len);
|
||||
}
|
||||
static int tty_write(int fd, void *buf, size_t len)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct tty_struct
|
||||
struct termios termios; //!< 当前使用的终端信息
|
||||
struct winsize w_size; //!< 窗口大小
|
||||
u_mutex_t lock_cons;
|
||||
u_mutex_t lock_write_cons;
|
||||
// u_mutex_t lock_write_cons;
|
||||
queue_t w_queue; //!< 写数据的缓存
|
||||
uint8_t w_queue_data[TTY_QUEUE_DATA_SIZE];
|
||||
queue_t pre_queue; //!< 然后通过handler处理机制存放到per_queue中,pre_queue中的数据直接可以给用户,或者进行回显
|
||||
|
||||
Reference in New Issue
Block a user