LKM kbuild и проблемы с файлами заголовков [duplicate]

более эффективен

def concat_df_str1(df):
    """ run time: 1.3416s """
    return pd.Series([''.join(row.astype(str)) for row in df.values], index=df.index)

, и вот время:

import numpy as np
import pandas as pd

from time import time


def concat_df_str1(df):
    """ run time: 1.3416s """
    return pd.Series([''.join(row.astype(str)) for row in df.values], index=df.index)


def concat_df_str2(df):
    """ run time: 5.2758s """
    return df.astype(str).sum(axis=1)


def concat_df_str3(df):
    """ run time: 5.0076s """
    df = df.astype(str)
    return df[0] + df[1] + df[2] + df[3] + df[4] + \
           df[5] + df[6] + df[7] + df[8] + df[9]


def concat_df_str4(df):
    """ run time: 7.8624s """
    return df.astype(str).apply(lambda x: ''.join(x), axis=1)


def main():
    df = pd.DataFrame(np.zeros(1000000).reshape(100000, 10))
    df = df.astype(int)

    time1 = time()
    df_en = concat_df_str4(df)
    print('run time: %.4fs' % (time() - time1))
    print(df_en.head(10))


if __name__ == '__main__':
    main()

final, когда используется sum (concat_df_str2), результат не просто concat, он преобразуется в целое число.

8
задан Manishearth 14 February 2013 в 15:08
поделиться

3 ответа

Вы ищете #include <linux/sched.h>. Вот где объявлено task_struct.

12
ответ дан cnicutar 26 August 2018 в 09:49
поделиться

Ваш код должен работать. Вероятно, вам не хватает заголовка.

current - переменная per-cpu, определенная в linux/arch/x86/include/asm/current.h (весь код относится к случаю x86):

DECLARE_PER_CPU(struct task_struct *, current_task);
static __always_inline struct task_struct *get_current(void)
{
    return percpu_read_stable(current_task);
}
#define current get_current()

current указывает на задачу, выполняемую на процессоре в данный момент. Его тип struct task_struct и определен в linux/include/linux/sched.h:

struct task_struct {
    ...
    pid_t pid;   // process identifier
    pid_t tgid;  // process thread group id
    ...
};

Вы можете просмотреть код для этих файлов в Linux Cross Reference :

7
ответ дан betabandido 26 August 2018 в 09:49
поделиться

Я думаю, что вы ищете системный вызов getpid () . Я не знаю, что current.

-3
ответ дан Rob I 26 August 2018 в 09:49
поделиться
Другие вопросы по тегам:

Похожие вопросы: